ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
525 stars 109 forks source link

System.ArgumentNullException: Value cannot be null. when building with .Net native toolchain #418

Closed ghost closed 3 years ago

ghost commented 3 years ago

I'm using Microsoft.Data.Sqlite and SQLitePCLRaw.provider.e_sqlite3.uwp and everything works when building without .Net native toolchain, and i was experiencing an error when building with .Net native toolchain which i solved by altering Default.rd.xml by removing and replacing it with assembly references to all the assemblies I'm using, after doing that i keep encountering this error:

System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property. ---> System.ArgumentNullException: Value cannot be null. Parameter name: type at System.Reflection.IntrospectionExtensions.GetTypeInfo(Type) + 0x7b at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() + 0xb3 at Microsoft.Data.Sqlite.SqliteConnection..cctor() + 0x8 at System.Runtime.CompilerServices.ClassConstructorRunner.Call(IntPtr) + 0x89 at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x247

--- End of inner exception stack trace --- at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext) + 0x351 at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstruction(Void, StaticClassConstructionContext*) + 0x17 at Microsoft.Data.Sqlite.SqliteConnection..ctor(String) + 0x44 at noobcloud.local_data.init(String) + 0x19e

connection was null.

I've noticed that i get:

Exception thrown: 'System.IO.FileNotFoundException' in System.Private.Reflection.Core.dll With e_sqlite3, but it's copied to the output directory. Maybe that's related to this issue.

ericsink commented 3 years ago

was experiencing an error when building with .Net native toolchain which i solved by altering Default.rd.xml

What was the original error?

ghost commented 3 years ago

Error RHBIND : error RHB0011: Internal error: 'pchTypeNameEnd[0] == L'>'' at 'f:\dd\ndp\rh\src\tools\rhbind\makepdb.cpp:968' appname.UWP Error ILT0005: '...\packages\runtime.win10-x86.microsoft.net.native.compiler\2.2.10-rel-29722-00\tools\x86\ilc\Tools\rhbind.exe @"...\obj\x86\Release\ilc\intermediate\rhbindargs.appname.UWP.rsp"'

ericsink commented 3 years ago

Oh wait. I just realized what Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() is.

@bricelam Any thoughts on the original question above?

bricelam commented 3 years ago

@siggi90 What version of Microsoft.Data.Sqlite are you using? We removed our .rd.xml file in 6.0.0, but AFAIK older versions should work with .NET Native...

ghost commented 3 years ago

Latest version, but i managed to solve the original issue by fixing a library i was using, which is unrelated to Sqlite.