Using couchbase lite on Windows, error when creating database

243 views
Skip to first unread message

Jsparrow

unread,
Jan 2, 2015, 7:31:32 AM1/2/15
to mobile-c...@googlegroups.com
Hello, I'm having a problem using couchbase lite on Windows 8.1 32bit. I have a C# WPF application, I downloaded couchbase lite from nuget and added it to my solution on visual studio. When I try to create the database file, I get the error: Unable to create a storage engine, fatal error. Here's the code:

 
public void openDb()
       
{
           
var dirInfo = Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory);
           
Manager manager;
           
Database db;
           
try
           
{
                manager
= new Manager(dirInfo, Manager.DefaultOptions);
                db
= manager.GetExistingDatabase("db");
               
if (db == null)
               
{
                    db
= manager.GetDatabase("db"); //error here
               
}
           
}
           
catch (Exception e)
           
{
               
MessageBox.Show(e.ToString());
           
}
       
}

I took a look at the source code and included it in my project just to check where the error was coming from and when it's executing the code inside the SqlitePCLRawStorageEngine class there's an open(string path); method which shows me the error:

var errMessage = "Cannot open Sqlite Database at pth {0}".Fmt(path);

A few lines after (still inside the open(string path); method), it throws an exception on this line:

var status = raw.sqlite3_open_v2(Path, out db, flags, null);

I noticed that the db parameter is null here, I don't know if that's intended or not but the exception says:
catch (Exception ex)
           
{
               
Log.E(Tag, "Error opening the Sqlite connection using connection String: {0}".Fmt(path), ex);
                result
= false;
           
}

The exception "ex" says: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Am I doing something wrong or does Couchbase Lite not support Windows applications? Is Couchbase Lite for mobile apps only?

Jens Alfke

unread,
Jan 3, 2015, 8:23:16 PM1/3/15
to mobile-c...@googlegroups.com

On Jan 2, 2015, at 4:31 AM, Jsparrow <regis...@gmail.com> wrote:

Am I doing something wrong or does Couchbase Lite not support Windows applications? Is Couchbase Lite for mobile apps only?

I don't work on the .NET version, but I believe it only supports Xamarin (MonoTouch) right now. Have you looked through the readme or the archives of this list?
Hopefully Zack can provide a definitive answer.

—Jens

Zack Gramana

unread,
Jan 3, 2015, 8:32:35 PM1/3/15
to mobile-c...@googlegroups.com
I haven’t Internet access in quite a while, but I happened to be sitting in a Starbucks in rural Georgia getting our Unified API component submission in before the deadline tonight. ;)

Yes, it does support Windows .NET 4.5 applications (for most people, that will be WPF, console, or ASP.NET).

The error you’re getting should go away with a rebuild. SQLite is not a standard lib on Windows, and we depend on a package to provide it (Eric Sink’s excellent SQLitePCL.raw). Sometimes VS inexplicably cleans it out of the bin folder. A rebuild (clean + build) seems to fix it.


--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/65749445-1E1A-446E-8A93-9CADF0F01E89%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Jsparrow

unread,
Jan 4, 2015, 12:12:10 AM1/4/15
to mobile-c...@googlegroups.com

Hello, thank you for your assistance. I have a WPF C# application running on .NET 4.5 and I downloaded the source from github, did clean+build and the build was completed with no errors, but unfortunately I still get the same error :/
I rebuilt it on a trial version of VS2013 Ultimate so I don't know if that caused any issues. I think I've rebuilt it correctly. If this issue can be fixed by rebuilding, would one of you guys mind to rebuild it correctly and provide me with the .dll?

Zack Gramana

unread,
Jan 4, 2015, 2:16:36 PM1/4/15
to mobile-c...@googlegroups.com
I would suggest just using the Nuget package.

On Jan 4, 2015, at 12:10 AM, Jsparrow <regis...@gmail.com> wrote:

Hello, thank you for your assistance. I have a WPF C# application running on .NET 4.5 and I downloaded the source from github, did clean+build and the build was completed with no errors, but unfortunately I still get the same error :/
I rebuilt it on a trial version of VS2013 Ultimate so I don't know if that caused any issues. I think I've rebuilt it correctly. If this issue can be fixed by rebuilding, would one of you guys mind to rebuild it correctly and provide me with the .dll?

Jsparrow

unread,
Jan 4, 2015, 9:40:49 PM1/4/15
to mobile-c...@googlegroups.com
I'm sorry, maybe I didn't explain myself properly. Like I said on my first post, I first got the package from Nuget. It was only after I got the error that I downloaded the source from github. But I believe I found the issue. My application used to run on .NET framework 4.0 but in order to use CBLite I went to the project's properties and changed framework to .NET 4.5. I tested the application and everything was working normally so I downloaded CBLite from Nuget and included it in the project. Apparently when you change the .NET Framework version of a project from 4.0 to 4.5 and then include CBLite it will always throw that exception. But if you create a new .NET 4.5 application from scratch and include CBLite it will work. I'm currently not home and didn't test this extensively but I think you should be able to reproduce the issue, in all the tests that I've done, that was what happened. I don't know if this is a bug with CBLite or VS2013 itself, but for now, it seems like the only solution is to re-create the whole application from scratch on .NET 4.5.

Ken Courville

unread,
Jan 5, 2015, 8:07:48 AM1/5/15
to mobile-c...@googlegroups.com
I'm just a cblite consumer, but this thread has me curious, since it's since I might run into.  

It sounds like you added the cblite nuget after switching from 4.0.to 4.5.  It's pretty common that if you did it before switching, you'd have to re-install the nuget package, since they can be framework version-specific.  I'm curious if running this command from the Package Manager Console would've fixed you:

  UPDATE-PACKAGE -Reinstall

.. keep in mind this upgrades all nuget packages. So, if you're not ready to update some packages, you can specify the cblite package explicitly.  Though, there could be other packages in use that need to be reinstalled as well.

  UPDATE-PACKAGE Couchbase.Lite -Reinstall

Jsparrow

unread,
Jan 5, 2015, 1:53:27 PM1/5/15
to mobile-c...@googlegroups.com
Yes, I only included cblite after changing from 4.0 to 4.5 but thanks for the sugestion anyway, I gave that a try, but unfortunately I still got the exception. From the tests I've done this is what I've found:

- Create new .NET 4.5 application from scratch --> download and include cblite from Nuget ---> Works!
- Create new .NET 4.0 application from scratch --> change framework to .NET 4.5 --> download and include cblite from Nuget --> exception thrown, doesn't work :(
Reply all
Reply to author
Forward
0 new messages