0
votes

I am stuck into a serious trouble with my build. I am using entity framework with sqlite in an UWP application. Everything works fine on debug mode, BUT when I run the app on release mode I got a lot of sqlite/entity framework exceptions:

Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.Data.Sqlite.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'Microsoft.Data.Sqlite.SqliteException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in Microsoft.EntityFrameworkCore.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in Microsoft.EntityFrameworkCore.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.EntityFrameworkCore.DbUpdateException' in System.Private.CoreLib.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.Threading.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

I noticed that if I uncheck "Optimize code" for release configuration, everything is back to normal. Something is happening at compilation. Does anyone have any clue about how to investigate this?

1
It's possible you're hitting problems with .Net Native stripping away type information. Perhaps see if working through this helps you: blogs.msdn.microsoft.com/dotnet/2014/05/21/…Johnny Westlake

1 Answers

1
votes

From the description its seems quite likely that the optimizer has botched something. One interesting check is:

  • Set to DEBUG config
  • Turn on .NET Native in the DEBUG config (Project Properties > BUILD > Enable .NET Native)
  • Build and see if it repros!

This config will disable the optimizer for your entire project. If it causes the issue to disappear then it’s just a hunt to see which methods/types we’re having trouble with. If it works in the DEBUG configuration but with .NET Native enabled then you may be able to get a working RELEASE build by selectively disabling the optimizer. Here’s an example of how to do this by Type/Namespace/Assembly:

  • Open Properties\Default.rd.xml
  • Add: <Type Name=”FullyQualified.TypeName” DoNotOptimize=”true” DoNotInline=”true”/>
  • Or: <Namespace Name=”Name.Space” DoNotOptimize=”true” DoNotInline=”true”/>
  • Or: <Assembly Name=”Assembly.Name.Without.Extension” DoNotOptimize=”true” DoNotInline=”true”/>

Disabling things one assembly at a time lets you make reasonable progress without driving yourself mad. If that strategy ends up working out for you, then you’re good to go. The Default.rd.xml file comes along when you submit your application to the Store so the Store compile will look more or less identical to your local compile.

If you do manage to narrow it down a bit I'm sure the folks who build the .NET Native optimizer would love to know more so that they can get it chase down out of the compiler. They're reachable at [email protected]