Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when attempting to export objects. #55

Open
pgrm opened this issue Mar 14, 2016 · 7 comments
Open

Error when attempting to export objects. #55

pgrm opened this issue Mar 14, 2016 · 7 comments
Assignees
Milestone

Comments

@pgrm
Copy link

pgrm commented Mar 14, 2016

I'm getting seemingly random errors when I try to export an object. Some complex objects work, others don't and than I get this error also when I try exporting a DateTime value.

Any chance I can see the underlying exception? Thx

@OmarElabd OmarElabd added the bug label Mar 14, 2016
@OmarElabd OmarElabd added this to the Version 2.0 milestone Mar 14, 2016
@OmarElabd OmarElabd self-assigned this Mar 14, 2016
@OmarElabd
Copy link
Owner

@pgrm not at the moment unfortunately, but i'm fully aware of the issue. The problem is that an invalid string such as "Cannot evaluate expression" is retrieved from the debugger and it's attempted to be cast as a DateTime, this causes the exception.

You might want to ensure that you are exporting the object in DEBUG mode, and make sure that the "Optimize code" is unchecked (it is by default).

In the very near future (After spring break) a new version should be out which will inform you which properties could not be exported due to the debugger.

Linked to #20

Exception Log:

 System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles):34
 ObjectExporter.Core.Templates.CSharpGenerator.GetSingleTypeValue(Expression expression):431
 ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):137
 ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
 ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
 ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
 ObjectExporter.Core.Templates.CSharpGenerator.TransformText():97
 ObjectExporter.Core.ExportGenerator.GenerateText(Expression expression, ExpressionSourceType source):108
 ObjectExporter.Core.ExportGenerator+<>c__DisplayClass1b.<GenerateTextAsync>b__1a():28
 System.Threading.Tasks.Task`1.InnerInvoke():15
 System.Threading.Tasks.Task.Execute():16
 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task):11
 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):40
 ObjectExporter.Core.ExportGenerator+<GenerateTextWithKey>d__8.MoveNext():407
 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task):11
 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):40
 ObjectExporter.VsPackage.Views.FormSelectObjects+<buttonExport_Click>d__2.MoveNext():420

@pgrm
Copy link
Author

pgrm commented Mar 14, 2016

Ok, thx for the info. Just one comment, I could see the values in the
visual Studio debugger. Or is that irrelevant?

On Mon, Mar 14, 2016, 17:55 Omar Elabd notifications@github.com wrote:

@pgrm https://github.com/pgrm not at the moment unfortunately, but i'm
fully aware of the issue. The problem is that an invalid string such as
"Cannot evaluate expression" is retrieved from the debugger and it's
attempted to be cast as a DateTime, this causes the exception.

You might want to ensure that you are exporting the object in DEBUG mode,
and make sure that the "Optimize code" is unchecked (it is by default).

In the very near future (After spring break) a new version should be out
which will inform you which properties could not be exported due to the
debugger.

Linked to #20 #20

Exception Log:

System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles):34
ObjectExporter.Core.Templates.CSharpGenerator.GetSingleTypeValue(Expression expression):431
ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):137
ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
ObjectExporter.Core.Templates.CSharpGenerator.ExportMembers(Expression expression, Int32 currentDepth, Boolean isLast):562
ObjectExporter.Core.Templates.CSharpGenerator.TransformText():97
ObjectExporter.Core.ExportGenerator.GenerateText(Expression expression, ExpressionSourceType source):108
ObjectExporter.Core.ExportGenerator+<>c__DisplayClass1b.b__1a():28
System.Threading.Tasks.Task`1.InnerInvoke():15
System.Threading.Tasks.Task.Execute():16
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task):11
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):40
ObjectExporter.Core.ExportGenerator+d__8.MoveNext():407
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task):11
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):40
ObjectExporter.VsPackage.Views.FormSelectObjects+<buttonExport_Click>d__2.MoveNext():420


Reply to this email directly or view it on GitHub
#55 (comment)
.

@OmarElabd
Copy link
Owner

Hmm, what type of object are you attempting to export? Is it a simple POCO? If the object has properties that are from different assemblies those might use a DateTime that couldn't be evaluated. If you can see all the values in the debugger then something else is going on.

@pgrm
Copy link
Author

pgrm commented Mar 14, 2016

ok, so I have 2 simple DateTime objects which don't work.

And I have some Entity Framework (EF6) models which also don't work. The later is either single objects or also IEnumerable<T> converted .ToArray(). And I've also managed to convert one EF6 model after changing the max depth allowed to 0 or 1. And it seemed to have been exported correctly, but I'll check tomorrow one more time, to be sure.

And I also had a simple string, Guid and POCO which all worked without any problems right away.

@OmarElabd
Copy link
Owner

EF6 models are another thing which i'm working on (see #23), because Entity Framework will add dynamic proxies to an object. You can try disabling the Dynamic Proxies and try re-exporting the object and see if that works.

More information:
https://msdn.microsoft.com/en-us/data/jj592886.aspx?f=255&MSPPError=-2147217396

@pgrm
Copy link
Author

pgrm commented Mar 15, 2016

ok, thx for the info on the EF issue - I guess that's my biggest pain. I think other poco did work and if the two datetime fields don't work I can live with that. That much I can copy paste from the debugger.

@goyaweb
Copy link

goyaweb commented Apr 11, 2019

I'm getting this error for every object I try, even a simple string.
Using vs.net 2015.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants