ericsink / SQLitePCL.raw

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

FileNotFoundException when running on Windows Phone 8.1 Silverlight #60

Closed markjulmar closed 9 years ago

markjulmar commented 9 years ago

Fails when trying to create the database with SQLite-net.PCL, here's the stack trace:

>   SQLitePCL.raw.DLL!SQLitePCL.SQLite3Provider.SQLitePCL.ISQLite3Provider.sqlite3_open(string filename, out System.IntPtr db = {System.IntPtr})    Unknown
    SQLitePCL.raw.DLL!SQLitePCL.SQLite3Provider.SQLite3Provider()   Unknown
    SQLitePCL.raw.DLL!SQLitePCL.raw.raw()   Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    SQLitePCL.raw.DLL!SQLitePCL.raw.sqlite3_open_v2(string filename = "C:\\Data\\Users\\DefApps\\APPDATA\\Local\\Packages\\5458be8c-a0f5-434c-9f10-b148eade3f75_6pk4qsq6wgqs2\\LocalState\\TaskDB.db3", out SQLitePCL.sqlite3 db = null, int flags = 6, string vfs = null)  Unknown
    SQLite-net.DLL!SQLite.SQLiteConnection.SQLiteConnection(string databasePath, SQLite.SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = true)    Unknown
    SQLite-net.DLL!SQLite.SQLiteConnectionWithLock.SQLiteConnectionWithLock(SQLite.SQLiteConnectionString connectionString, SQLite.SQLiteOpenFlags openFlags)   Unknown
    SQLite-net.DLL!SQLite.SQLiteConnectionPool.Entry.Entry(SQLite.SQLiteConnectionString connectionString, SQLite.SQLiteOpenFlags openFlags)    Unknown
    SQLite-net.DLL!SQLite.SQLiteConnectionPool.GetConnection(SQLite.SQLiteConnectionString connectionString, SQLite.SQLiteOpenFlags openFlags)  Unknown
    SQLite-net.DLL!SQLite.SQLiteAsyncConnection.<>m__0()    Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task<SQLite.CreateTablesResult>.InnerInvoke()    Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.Execute()   Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.ExecutionContextCallback(object obj)    Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)    Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot = Id = 1, Status = Running, Method = "SQLite.CreateTablesResult <>m__0()", Result = "{Not yet computed}")    Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution)  Unknown
    mscorlib.ni.dll!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()  Unknown
    mscorlib.ni.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown
    mscorlib.ni.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()  Unknown

Same code works fine with Xamarin.iOS and Xamarin.Android.

markjulmar commented 9 years ago

Here's a sample project which has the issue, perhaps I'm missing some reference or extension library in the Windows Phone project, but I could swear this used to work just fine..

https://www.dropbox.com/s/5qqg18tt8uhl6bq/TaskyPro.zip?dl=0

ericsink commented 9 years ago

All instances of this error have been caused by a missing extension SDK. So far. :-)

Have you by chance switched to Visual Studio 2015? I've heard somebody say that there is another extension SDK needed. You need the Visual C++ runtime (which I think you already know), but you also need another one, and I forget the exact name. I think it had the words ".NET Native" in it.

markjulmar commented 9 years ago

I am on VS2015 -- let me give that a shot!

markjulmar commented 9 years ago

Works once you add the proper extension SDKs -- thanks Eric!

pinturikkio commented 8 years ago

So, which is the name of the missing extension? How you've solved the problem?

ericsink commented 8 years ago

I don't have the exact name handy. It's probably the Visual C++ 2013 Runtime, or something like that.

dach89 commented 8 years ago

Hello.

I'm having what look like the same problem. Even after i added the Visual C++ 2013 Runtime, but still same error

My code look like this

var sqliteFilename = "MySQLite.db3";
            string path = Path.Combine(ApplicationData.Current.LocalFolder.Path, sqliteFilename);
            var conn = new SQLite.SQLiteConnection(sqliteFilename );
Exception thrown: 'System.IO.FileNotFoundException' in SQLitePCL.raw.ni.DLL

can anyone see if i been doing something wrong?

ericsink commented 8 years ago

Just a stab in the dark: One other user reported the need to add another extension SDK, something with the word "native" in the name.

dach89 commented 8 years ago

are you talking about this? https://github.com/ericsink/SQLitePCL.raw/issues/44#issuecomment-149568758

doesn't seems to be possible to add to a windows phone 8.1 project. so not sure what to do

ericsink commented 8 years ago

Yeah, you're right, that seems unrelated.

Just to be sure: Is SQLite itself being added to your project?

Like, in your output build directory, there should be a sqlite3.dll somewhere. For some platforms, it is provided by SQLitePCL.raw. In some cases that is controlled by the MSBuild property UseSQLiteFrom. (I'm not sure about this, as I am having trouble remembering details about SQLitePCL.raw for the Win81 SL platform). If it is not coming from SQLitePCL.raw, you have to add the SQLite extension SDK.