sqlite3.dll causes error under Windows 7 x64

1,748 views
Skip to first unread message

Francesco

unread,
May 4, 2011, 8:50:08 AM5/4/11
to ServiceStack .NET Open Source REST Web Services Framework
Hello,

I am not able to run your ServiceStack examples that contains
sqlite3.dll neither in VS2010 nor in IIS. The error always refers to
sqlite3.dll.
I have enabled IIS application pool to run 32 bit applications.
My machine runs Windows 7 x64. Target platform in VS project is x86.

Thanks,
Francesco

Tim Ryan

unread,
May 4, 2011, 8:56:20 AM5/4/11
to servic...@googlegroups.com
Francesco,

You might have a 64bit sqlite dll? Does it give you a bad format exception? The built in VS web server runs as a 32bit process I think. You can drop in 64bit CassiniDev to run as 64 bit.

Thanks Tim

Francesco Paolo Santi

unread,
May 4, 2011, 9:01:21 AM5/4/11
to servic...@googlegroups.com
Hi Tim,

I receive the following exception:

Unable to load DLL 'sqlite3': Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

In this piece of code of MoviesService.cs (line 150):

public override object OnGet(Movies request)
{
return new MoviesResponse
{
Movies = request.Genre.IsNullOrEmpty()
? DbFactory.Exec(dbCmd => dbCmd.Select<Movie>())
: DbFactory.Exec(dbCmd => dbCmd.Select<Movie>("Genres LIKE {0}", "%" + request.Genre + "%"))
};
}



Thanks,
Francesco

Demis Bellot

unread,
May 4, 2011, 9:13:35 AM5/4/11
to servic...@googlegroups.com
Hi Francesco,

Here's another description of the problem:

Unfortunately the use-case of running 32bit dlls under IIS is a configuration issue which can be problematic at times and you need to tweak a few things to run properly:

Basically you should ensure that the Host project (i.e. the ASP.NET application project) of the solution you're running is set to compile to x86, see the attached screen shot. 

I also have Win7 x86 and am able to run it in this way (with the App Domain set to enable 32 bits). 
 - You should run VS.NET in admin mode (i.e. Run as Administrator if not already)
 - You may want to try running in its a new AppDomain on its own if you have problems.

Otherwise as a final resort you can change the project references to include a 64bit build of Sqlite available from here:

In which case you will need to replace the dll references 'Mono.Data.Sqlite' and 'ServiceStack.OrmLite.Sqlite' with 'ServiceStack.OrmLite.SqliteNET.dll' and 'System.Data.SQLite.dll' 

Note: these 64bit dlls no longer uses sqlite3.dll and only runs on Windows (i.e. not Linux/Mono) and it uses the embedded 'System.Data.SQLite.dll' instead:

Let me know if it helps.

Cheers,
Demis
--
- Demis


x86-sqlite.png

Francesco

unread,
May 4, 2011, 9:31:34 AM5/4/11
to servic...@googlegroups.com
Hello Demis,

I am already running VS as Administrator and the project build is set to x86.
I have also tried to reference the libraries you suggested to me without success.
Please see attached image.

Do you have any other idea to help me overcoming this issue?

Thanks a lot,
Francesco



Demis Bellot

unread,
May 4, 2011, 9:36:10 AM5/4/11
to servic...@googlegroups.com
Well if you're using the 64bit dll you don't want to compile to x86.

Does it work when you switch it back to 'Any CPU' and do a clean/rebuild all?


Francesco

unread,
May 4, 2011, 9:52:45 AM5/4/11
to servic...@googlegroups.com
I've finally made it work.
I've set the build target to Any CPU.
Moreover I've replaced the suggested dlls with the 32bit version (with the x64 it was still giving me error):
https://github.com/ServiceStack/ServiceStack.OrmLite/downloads
In which case you will need to replace the dll references 'Mono.Data.Sqlite' and 'ServiceStack.OrmLite.Sqlite' with 'ServiceStack.OrmLite.SqliteNET.dll' and 'System.Data.SQLite.dll'
In any case the solutions seems weird to me but at least we made it work.
Thanks again,
Fracnesco 

Demis Bellot

unread,
May 4, 2011, 10:00:29 AM5/4/11
to servic...@googlegroups.com
Sweet, I'm glad you got it to work...

Yeah 32bit support in IIS is annoying. 

It's hard to make a web project using unmanaged dlls work on both 32bit and 64bit web servers on Windows and Linux.

I've managed to do this with the Sqlite projects (i.e. it works on my 32 and 64bit machines TM :) but as you've noticed requires some configuration / tweaking.

The alternative is to cut 32 and 64bit windows projects and another for Mono for the same solution but IMO this complicates the examples and increases the management burden.

Life will be much simpler when 32bit machines no longer exist :)

Cheers,
Demis

Francesco

unread,
May 4, 2011, 10:06:21 AM5/4/11
to servic...@googlegroups.com
Yep, change is usually painful, and that was a clear example!!! :)
Unfortunately 32bit will stay on the scene for a while IMHO. 

Thanks again for your blazing fast support. I really appreciated it.
Francesco.

Rui Marques

unread,
May 4, 2011, 10:15:55 AM5/4/11
to servic...@googlegroups.com
I've heard, and also experience tels me that, running all app pools in 32 bits mode on x64 Windows 2008 boosts performance and IIS responsiveness.

When I setup a new Windows 2008 x64 box I make that as a default for new application pools.

Tim Ryan

unread,
May 4, 2011, 4:36:28 PM5/4/11
to servicestack
Rui,

There are memory limitations with running 32bit mode, i.e. 2gb per process (although there is a 3gb switch). With 64bit mode your IIS app pools can use all of you physical RAM on a 64bit box.

Thanks Tim

Tim Ryan

unread,
May 4, 2011, 4:43:07 PM5/4/11
to servicestack
The important part with dealing with native libraries is the entry point. When hosting in 32bit environment all native libraries must be 32bit, it doesn't particularly matter whether you have Any CPU or x86 with a ASP.NET site as it isn't the entry point. The entry point decides the architecture which in this case is the host.

If you want to be able to switch easily between the two I suggest using CassiniDev and fire it up from the command line in Web properties page.

Francesco

unread,
May 5, 2011, 2:43:53 AM5/5/11
to ServiceStack .NET Open Source REST Web Services Framework
@Tim

In my case the architecture is x64...But I had to reference 32bit dlls
because with x64 it was not working.
I'll take a look to CassiniDev.

Thanks,
Francesco

On May 4, 10:43 pm, Tim Ryan <tim.pl...@gmail.com> wrote:
> The important part with dealing with native libraries is the entry point.
> When hosting in 32bit environment all native libraries must be 32bit, it
> doesn't particularly matter whether you have Any CPU or x86 with a
> ASP.NETsite as it isn't the entry point. The entry point decides
> the architecture which in this case is the host.
>
> If you want to be able to switch easily between the two I suggest using
> CassiniDev and fire it up from the command line in Web properties page.
>
> http://cassinidev.codeplex.com/
>
> <http://cassinidev.codeplex.com/>
>

Rui Marques

unread,
May 5, 2011, 5:21:35 AM5/5/11
to servic...@googlegroups.com
Tim,

I agree 100% about the limitations you mention. We need to consider the scenario we have when running an web app/site. On a web server were we have multiple websites we need to control memory usage and the need for more than 2GB per process will depend on the king of service running, the need for cache (using IIS native, managed at application level, having a front-cache appliance, etc, etc,... ), pool recycling settings, etc.
Reply all
Reply to author
Forward
0 new messages