Aug 10, 2008 at 12:01 AM

I get this exception when I try to run N2 on IIS7 instead of Cassini. The exception is thrown when I load the root of the site, ie nothing is accessible.

System.BadImageFormatException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I looks like other users of SQLite have had the same problem:

I'm also on Vista 64 bit.

Any ideas?
Aug 10, 2008 at 12:52 AM
Try to download and use the 64 bit version of the library.
Aug 10, 2008 at 11:44 AM


I got the 64 bit version and got another error.

I'm using the complete source. I just copied the SQLite dll into the Templates.UI bin directory.

The new error I get is:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 30:                 if (!status.IsInstalled)
Line 31:                 {
Line 32: context.Response.Redirect(config.Installer.InstallUrl);Line 33:                 }
Line 34:             }

Source File: C:\projects\test\N2CMS\Source\src\N2\Installation\InstallationChecker.cs    Line: 32

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Web.HttpResponse.End() +183
   N2.Installation.InstallationChecker.Start() in C:\projects\test\N2CMS\Source\src\N2\Installation\InstallationChecker.cs:32
   N2.Engine.ContentEngine.StartComponents(IKernel kernel) in C:\projects\test\N2CMS\Source\src\N2\Engine\ContentEngine.cs:243
   N2.Engine.ContentEngine.Initialize() in C:\projects\test\N2CMS\Source\src\N2\Engine\ContentEngine.cs:225
   N2.Context.Initialize(Boolean forceRecreate) in C:\projects\test\N2CMS\Source\src\N2\Context.cs:44
   N2.Web.InitializerModule.Init(HttpApplication context) in C:\projects\test\N2CMS\Source\src\N2\Web\InitializerModule.cs:18
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +479
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +335
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +349
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +381

[HttpException (0x80004005): Object reference not set to an instance of an object.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11312150
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4348404

I want to use SQL Server 2005 and I have set up the database and changed the connection string in web.config. I have also completed the installation (using Cassini).

What I'm trying to do is using multiple host names and this problem occurs when I try to browse the site on IIS7.
Aug 10, 2008 at 12:12 PM

Debugging some points out the it is the database connection that wasn't working ok.

I had trusted connection which worked ok with Cassini since I had started VS as administrator, but then in IIS7 I had the default AppPool setting (with Network Service as the process user).

Sorting the rights out solved that problem.

However, to give you some feedback about the problem, I couldn't really figure out which object caused the NullRefException. When I was debugging, all objects looked ok. You might want to have a look at that still though.
Aug 10, 2008 at 2:24 PM
Thanks for telling. I've fixed the bug.