Asp.net 3.0 and 64 bit sqlite dll file - asp.net

Greetings!
I am developing Asp.net application, in which i need to use sqlite as database, i tried to add reference to 64 bit dll file System.Data.SQlite file.
When i run my application it shows as below error
Error 1 Could not load file or assembly 'SQLite' or one of its dependencies. An attempt was made to load a program with an incorrect format.
What will be the reason for this, and how can i fix this.I am using visual studio 2010.
Thanks in advance
sangita

is your application built to target 64 bit? Or is it built to target AnyCpu and running on a 64 bit platform?
Have you tried using the 32 bit version of SQLite? It sounds like you are trying to load the 64 bit version of the dll when you are in a 32 bit environment...

Related

Click once deployment MS outlook addoin getting issue System.BadImageFormatException

I have built outlook add-in using Visual studio 2015 Professional Addition. And used Click once deployment to push to ftp location so that it can be auto updated when ever version change happens.
It was working fine from past 3 years.
Now I am using Visual Studio 2015 community addition to do some changes and when I am trying to push changes I am getting error as
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
I am using SQLlIte interop service and SQLLite3 database now it is not able to use that service.
Thanks in advance for the help
It seems you are trying to load a 32 bit dll into a 64 bit process (or the other way around). You may find the following similar threads helpful:
BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
"An attempt was made to load a program with an incorrect format" even when the platforms are the same
Make sure that your add-in dependencies support x64 and x86 platforms. Remember that you can't load and run x86 assemblies in the x64 process (or x64 assemblies into x86 process).
Initial build that was using 32 bit sql lite dll file.
Now I try to download and copy latest 64 and 86 SQLite.Interop.dll files into respective folders now it is working dll reference link
https://www.nuget.org/packages/SQLite.Interop/

Oracle.DataAccess.dll can not be located though it exists

When I browse ASP.Net application developed in Visual Studio 2008 on IIS 7.5(Windows Server 2008 R2 x64) I get configuration error stating that Oracle.DataAccess, Version=2.111.7.20 file could not be located. I've already installed Oracle Data Provider for .NET which contains the file. When I setup ODP.net it places the dll files into c:\app....\odp.net\PublisherPolicy folder. I just in case copied those files to C:\Windows\Microsoft\Framework folder too, but still I got the same error. Could someone please help me solve this issue? Any help is greatly appreciated
The ODP.NET installation can be very tricky. There are many things that can go wrong:
You can have a version mismatch (2.111.7.20 vs 2.112.1.0 vs. 2.112.2.0).
You can have a mismatch between 32 and 64 bit.
The .NET DLL might exists but one of the dependencies is not found.
Try to check the 32/64 bit mismatch first. In IIS, you can configure whether your web application runs as 32 or 64 bit. To check it, have a look at the task manager and see whether the w3wp.exe process has the *32 mark. Then go to C:\Windows\Assembly in the file explorer. It's a special view that display the GAC. If it says x86 in the last column on the row Oracle.DataAccess, then it's 32 bit. If it says AMD64, then it's 64 bit.
On the same row, you'll also find the exact version number. Check in VisualStudio, whether the ASP.NET project uses the same one.
If I'm not mistaken, the main dependency of Oracle.DataAccess.dll is OraOps11w.dll, which should be available in the BIN directory of the Oracle client directory. This directory is usually located via the registry (HKLM\SOFTWARE\ORACLE\ODP.NET\<version>\DllPath). Make sure you look at the registry of the correct bitness (32 vs 64 bit).
There are more things that can go. But these here usually solve the problem.

How to generate a 32bit only Managed C++ Assembly

I need to compile a DLL in Managed C++ in Visual Studio 2005.
I want it with 32Bit corflag on. See http://illuminatedcomputing.com/blog/?p=117 for reference.
By default, I choose Win32 platform and set the /MACHINE:X86 option in the liker, but the DLL generated has the 32bit corflag off. You can see it by executing from command line
corflags MyDll.dll
I have problems when running that dll in a Windows 64 bit. So I need to force the dll to 32 bit.
Any idea on how to configure the Visual Studio 2005 compiler?
You can actually use CorFlags.exe to set this. In the command line:
corflags MyDll.dll /32BIT+
This will set the 32 bit flag for MyDll.dll.
For more information see the corflags tag wiki.

Win 7 and ODBC with 64 bit

I am developing an ASP.NET Application and am trying to use the 64-bit driver version of ODBC on my 64 bit win 7 machine, because the deployment server has Windows Server 2008, which is naturally in 64 bit, since Microsoft decided not to make a 32 bit version afaik.
The first issue was an System.Data.Odbc.OdbcException "ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application". Despite the fact, that I am developing on a 64 bit operation system, the compiler seems to have decided to compile for 32 bit. After some research I changed the target platform to x64 in every of my (own) assemblies. I am using NHibernate and Spring.Net, but I read somewhere that 64 bit is no problem for NHibernate. I did not check Spring.Net yet. The compilation began.
I got some warnings that quite every .net assembly is built for another platform, but I read somewhere again that I can ignore these warning and the application should run just fine because the runtime (or compiler?) will figure out the right assembly.
So I tested the application right away and was rewarded with an System.BadImageFormatException (wrong format). It was again an exception concerning 32/64 bit issues although every one of my assemblies is compiled as 64 bit.
I am slowly starting to hate 64 bit. Seriously. Is it that difficult to build an 64 bit application on an 64 bit operation system for a 64 bit server with 64 bit drivers?
Does anybody have a solution or have experience with this issue? I found many workarounds with using 32 bit, but that is not an option here. It has to be a 64 bit solution.
Nevertheless I will continue trying for myself to solve this. I will write any progress here.
Update:
Spring.Net seems to be just fine on 64 bit since the assembly is "dynamically compiled at runtime to the native machine architecture".
i fought with this same error for several hours. My environment was slightly different, but the error was the same. I was using SSRS, Report Builder 3 and SQL Server 2008 R2 on a Win Server 2008 R2 x64 Box
I could create connections and test them successfully in SSRS, but when i would use them, i got the error above. It was resolved when i created a 32bit DSN of the same name and parameters.
I usually try to go other way: If I don't need any native in-proc DLLs, I use AnyCPU. So final program can be used on both x86 and x64. If I need native in-proc DLLs, I always chose x86 32bit version, because it is much easier to make it work correctly, and IMPORTANTLY I don't need any 64bit features. So why 64bit version? I just go to IIS configuration and setup my asp.net application to run in 32bit mode.
For example my current deveopment environment is fully 64bit and works perfectly. But my production server is setup to host my app in 32bit mode. It works perfectly, no 64bit issues. I apologize if this answer is not good for you, but I really never needed 64bit stuff in my asp.net applications.
update: I use 32bit IIS on production server. I am not sure if it is possible to setup asp.net as 32bit in 64bit IIS.

DLL File for windows 7 64bit

I'm porting my Windows XP application (wrote with C#) to Windows 7 application.
Now I'm using sqlite3.dll on my XP App (32bit) and I would download sqlite3.dll for 64bit machine.
For my purpose I've moved sqlite3.dll on my /bin folder and, obviously, when I try to start my app on windows 7 I receive an error.
So, where I download this file?
Please, help me...
Edit: I've downloaded sqlite3 http://www.sqlite.org/download.html
The SQLite website only has the 32-bit .dll, to get a 64-bit one you'll have to download and compile the source yourself.
Since you're using C#, an easier way is to use System.Data.SQLite ( http://sqlite.phxsoftware.com/ ). They have a 64-bit download available, which is SQLite itself and their ADO.NET provider combined into one .dll. It's the easiest way to use SQLite on Windows with C# I think.
Update: New download URL is http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
bin/x64 directory contains 64-bit NATIVE DLL, named System.Data.SQLite.dll which is SQLITE3.dll compiled for AMD64/X86_64 platforms.
The url is:
http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.66.0/
(IF it was you`re looking for).
Download SQLite-1.0.66.0-setup.exe from
http://sourceforge.net/projects/sqlite-dotnet2/files/SQLite%20for%20ADO.NET%202.0/1.0.66.0/
Run this executable will create a folder under C:\Program Files (x86)\SQLite.NET
Pick the System.Data.SQLite.DLL from bin/x64 and renamed it to sqlite3.dll
-- and you are good to go.
For your case, since your app was already written, you won't want to rewrite it.
You can simply recompile your .NET project targeting to 32 bit.
Right click your project-> properties -> build -> platform target : x86
64 bit app can only run on 64 machine while 32 bit app can run on both.

Resources