Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

P/Invoke warnings when building a UWP app with SQLite

When building a UWP app with SQLite added I'm receiving ~40 warnings like the following (just the method name changes) (added some new lines for better readability). The configuration is set to release. I'm not receiving any of these messages in debug mode.

C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\ARM\ilc\IlcInternals.targets(936,5): 
    warning : ILTransform_0000:       
    MCG : warning MCG0006: 
        Unresolved P/Invoke method 'Open!sqlite3' in assembly 
        'SQLite.Net.Platform.WinRT, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null' 
        because it is not available in UWP applications. Please either use an another API , 
        or use [DllImport(ExactSpelling=true) to indicate that you understand the 
        implications of using non-UWP application APIs. 

According to many tutorials I have the following references in the project.

  • SQLite for Windows Universal Platform that is installed via the sqlite-uwp-3120200.vsix file from sqlite.org
  • Visual C++ 2015 Runtime for Universal Windows Platform Apps (tried with and without this extension as some tutorials differ on whether it needs to be added or not)
  • SQLite.Net-PCL (v3.1.1) installed via NuGet

The target and min versions of this are 10586. As it is build in release mode the use of the native toolchain is enabled.

Does anyone know what this warning message means and how to solve it?

like image 406
Stephan Avatar asked Nov 09 '22 14:11

Stephan


1 Answers

I had similar issue when dealing with UWP unittest - no issue in debug mode only in release mode.

I solved it by changing UseDotNetNativeToolchain to false.

Look inside your .vcxproj file

<UseDotNetNativeToolchain>false</UseDotNetNativeToolchain>

like image 82
serup Avatar answered Nov 14 '22 21:11

serup