System.Data.SQLite.dll - System.IO.FileNotFoundException - c#

I use SQLite and works fine on the developer machine (or machine with Visual Studio).
But it does not work on PCs without VS. I "installed" the SQLite manually (32 bit version, added to the references, Copy Local: True). I get "System.IO.FileNotFoundException" System.Data.SQLite.dll exception.
The System.Data.SQLite.dll is in the output folder.
But I can not get it to work only if I install the SQLite with this: https://system.data.sqlite.org/downloads/1.0.105.2/sqlite-netFx46-setup-bundle-x86-2015-1.0.105.2.exe
Dev PC: x64 Win 10, application: x86 only
Please let me know if you need any other information.

Check which dependencies has your executable file (and, maybe, System.Data.SQLite.dll) with Dependency Walker or similar program. Then put these libraries you found into executable's folder one by one, until your executable will work.

You need to make sure the 64 bit C++ runtime DLLs are getting installed. They'll often be on the developer's system but not as often installed by your installer on the target system. Even though this is a .NET assembly, it appears to have C++ underpinnings.

Related

ActiViz.NET.x64 (v5.8.0): Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll'

I'm trying to use the VTK with C# to read and write VTK/VTS files. I created a basic app, and I installed the 64-bit VTK .NET wrapper package which is called ActiViz.NET.x64 (v5.8.0).
The package installed without any problems, and I could access the Kitware.VTK namespace, but as soon as I try to create a VTK object, I got an unmanaged DLL loading error.
An unhandled exception of type 'System.DllNotFoundException' occurred in Kitware.VTK.dll
Additional information: Unable to load DLL 'Kitware.VTK.vtkFiltering.Unmanaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I don't think that the exact code is relevant here, but I got the exception at the following line:
vtkStructuredGrid structuredGrid = vtkStructuredGrid.New();
I'm using Windows 10 x64, Visual Studio 2015, the target .NET Framework is 4.6.2 and I have ParaView 4.1 and 5.2 installed. The DLL in question is in the bin directory of the app, but I also tried to copy it to the Windows/System32 directory, the result is the same.
Is there a way to figure out what exactly the problem is with the dll loading?
If you go to the ActiViz product page you can see the following in the FAQ:
Does ActiViz 64 work with Visual Studio?
Visual Studio is a 32 bits
application, therefore 64 bits control does not work and you need the
32 bits version of ActiViz when using the designer within Visual
Studio. Usually, the 32 bits version is used to design and the 64 bits
version is used for the final compilation.
I also use VTK/ActiViz (C#) on Visual Studio, and it works fine when my program is targeting x86 platforms. However, if I target x64 platforms, the winforms control for the render window disappears, but I can still build the executable. So do this:
1) Install Activiz.NET.x86 from NuGet & target x86 platforms;
2) Create and debug your App;
3) Make a backup of the solution folder;
4) Install Activiz.NET.x64 from NuGet & target x64 platforms;
5) Don't open the designer because it will be buggy (all RenderWindowsControl disappear);
6) Build the solution (Release x64).
So, first I wanted to know where exactly is my process looking for the missing DLL. I used Sysinternals Suite and its Process Monitor.
I referenced VTK in my .NET library which I used in my self-hosted app. The self-hosted app was the start-up project, so the runtime looked for the missing DLL in the app's directory, not the library's, where it actually was.
After I copied the missing Kitware.VTK.vtkFiltering.Unmanaged.dll to that directory, Process Monitor confirmed that the DLL was read successfully, but I still got the same exception as before.
I compared the library's and the app's bin directories, and I figured that only the Kitware.mummy.Runtime.dll and Kitware.VTK.dll were copied there automatically.
I copied all the other VTK DLLs to the app's bin, and then it finally worked.
The exception's error message wasn't detailed in the first place, but I think it is more likely a problem with the ActiViz.NET package.
You should copy all dlls from Activiz Installation bin directory even you don't need to use in your code.
C:\Program Files (x86)\ActiViz.NET 5.8.0 OpenSource Edition\bin
Managed .Net DLL's is a wrapper for unmanaged VTK libraries. Mummy.dll is for this job.

DLL not found on target machine

I am having a similar problem.
I have developed a c# app that is Pinvoking a dll which is dependent on some other dlls. On dev machine it is working fine. Even when i copy the debug folder, which contains all the dlls and exe file, to a different location it works fine.
When I copy the same folder to another machine, it gives the dll not found exception.
The interesting thing is that the error message gives a path to the code file present on the dev machine. Not sure how this information is known at the target machine?
I have tried both the debug and release versions, but release version just crashes, and the debug version gives the exception message.
I have tried the dependency walker but could not figure out if there is any missing dependent dll causing the error.
I have tried to install VC++ run time redistribution package as well but it did not work.
I am using VS2013 on Win 7 64bit on dev machine. The target is Win 7 64bit.
Dlls are related to tesseract OCR and copied from here.

Compiling OLEDB dependent executables on x64

I compiled my executable that used the Access Database Engine libraries on Windows XP 32bit.
Running that on the Win7 x64 OS gave me an error that the OLEDB components were not registered.
I tried to install the AccessDatabaseEngine x64 and it fixed the problem.
However on another machine with Win7 x64 and office 2007 32bit installed, it wouldn't let me install the AccessDatabaseEngine x64 and so I was left to compile the project on that target machine (in VS2010 c#) with the Env as x64 and target CPU as x86. This fixed the problem.
My question is, why does this work? What's the reasoning behind this?
Thanks.
The answer your question what you are stating means that there for one is a different OS but should not matter.. the real issue here is that there are 2 different versions of Microsoft Installed.. you would have to either
GAC the version or Reference the version of the Target Machine
Set Copy Local of the .DLL in the working version to the Target version.. sort of like where your DLL's would reside in the Debug/Bin or Debug/Release folder where the bin folder resides..
I am working on Windows 7 64 bit and copied my working dll's over to a Windows 2003 server machine and my projects still work..
my other work around was to reference the Microsoft.Interop.Access .dll's from the Target machine into my Solution, recompile and Bam....!

Why might I get a DLL not found exception on Vista but not XP?

I have an app that relies on several managed libraries. These managed libraries in turn rely on some unmanaged libraries.
When I deploy the app to a machine running XP, it runs fine. When I do the same on a machine running Vista, I get a DLL not found exception.
I've tried both a VS2010 setup project and an NSIS installer to do the deployment and it's the same in both cases.
Why might this happen? What can I do to get around it?
Update - Further details
Both installers check for the installation of .NET 4.0 and install it if need be
The Vista computer is 64 bit, but the installation gets directed to the x86 program files folder as expected
In both cases I have an admin account
The DLLs are kept in the same directory as the executable
As far as I can tell, the files are getting copied to the right directory
Update 2
The full error is at http://pastebin.ca/2046487
The DLL is Audiere.Net.dll, which is one of mine and is a managed library.
I'm not sure if that error means that it can't find Audiere.Net.dll, or whether it can't load it because one of it's dependencies can't be found.
Update 3 - Stuff from Process Monitor
After running process monitor (thanks Mehrdad!) there are several entries which don't have a status of "SUCCESS". Some of these are "NAME NOT FOUND" and some are "PATH NOT FOUND". (It's even querying the PDB files, which I had thought were only used by a debugger.) It's really hard to see which entries might be the one leading to the actual failure. Anyway, I've uploaded the log (filtered to have a relevant path) in case it means something to anyone.
Update 4 - Added .pdb files
So I kinda got desperate and included the .pdb files to the output of the installer. I thought it would be useless, but it actually resulted in a more useful error. Rather than simply saying DLL not found, I now get a BadImageFormatException. Googling this tells me that this is a common problem for binaries compiled on x86 but being run on x64 (as the Vista machine is).
The suggested remedy is to force it to target x86, but Audiere.Net.dll already was. Could the fault lie with the library that it wraps?
Maybe there's some sort of redirection that's not actually letting your app install in the intended folder?
We'd need a bit more detail, but are you installing for the user or the machine? Are you an admin? Where is the DLL normally located?
Edit: Try using Process Monitor to monitor what file is actually being accessed.
If you are running a .Net application, do both computers have the proper Framework installed?
You mention that Audiere.Net.dll is targeted at x86, but what about your executable?
You can obviously recompile your program or use Corflags (part of the framework) to view the current setting on your exe.
Corflags ssd2.exe
Or to set or unset the flag
Corflags ssd2.exe /32BIT+
Corflags ssd2.exe /32BIT-
(Note, if your app is signed with a strong name it won't work unless you use /Force to remove the signature)
The solution turned out to be quite straightforward: one of the unmanaged DLLs needed to be recompiled for x64.
Key steps:
Check process monitor for likely sources of error. Look carefully at the error report that Windows offers to send when the app crashes.
Include the .pdb files for managed libraries. This seemed to result in more informative error messages.
These error messages not only specified which managed library was causing the error, but also indicated that it was a x86/x64 issue. (BadImageFormatException)
Following some sound advice, check that all of the unmanaged libraries are targeting x86. (Mine were, but it's good to be sure.)
Recompile the unmanaged dependencies of the troublesome managed library on an x64 machine.
Write an install script that copies the appropriate (x86 or x64) version of the DLL.
Profit!
Specifics:
The problem I had seemed to be with Audiere.Net.dll, but was actually caused by a problem with libaudieresharpglue.dll.
I use NSIS for installers. To accomplish the architecture specific DLL, I used a header called x64.nsh.
Usual reason is that the dll in question depends on other dlls which are not on the Vista machine (or possibly there but not registered.)
We ran into something simlar and found we needed to download the c++ Redistibuatable Package to get the program to run on windows 7 using 3rd party dlls.
I recall running into a similar issue with SQLite wrapper.
The source of the problem is the 32/64 bit issue of course, and it's the same scenario as the SQLite wrapper is a managed wrapper which makes it processor dependent.
I am guessing that while you're managed lib (Audiere.Net.dll) is compiled for 32 bits, you main application (ssd2.exe) is not.
The installation folder is determined by the configuration of the setup, but if the application project is not strictly configured to compile as a x86 project (usually targeting the default Any Cpu environment) then the application will launch as a 64 bit process, regardless of the installation path. This can be easily verified by looking at the process in task manager on a 64 bit machine, all 32 bit processes have an additional *32 on a 64 bit windows machine (they won't have it on a 32 bit machine).
EDIT: or more easily by looking at the project properties->Build-> Platform Target :)
Anyhow - you should change the project settings for the project that builds ssd2.exe to target x86 and you should be ok.

App with many assemblies forcing 32-bit

I have a VS solution with many assemblies and third-party utilities. I need to force the app to run 32-bit when running on a 64-bit machine. The app runs just fine on a 32-bit machine. I forced the .exe file to be only 32-bit required and when run on the 64-bit machine, I am getting "an attempt was made to load a program with an incorrect format" error. It was my understanding that changing the exe would force all the assemblies to load as 32-bit. What is going on?
I know this is an old question; maybe you already found your answer.
I'm not familiar with setting ILONLY and 32BITREQUIRED... usually choosing x86 instead of ANYCPU in the compiler drop-down box before compiling takes care of everything you need. You can verify that all your apps are set to compile to x86 in the configuration manager, as well.
Most likely, what you're running into is that one of your third-party utilities installed a 64-bit DLL on the 64-bit machine, and your forced-32-bit application is trying to load a 64-bit DLL. If a third-party DLL has a 32-bit and 64-bit version, chances are the installer is smart enough to know which one to lay down.
Two places you can go on the 64-bit machine to check:
If the program installed to C:\Program Files\, it's a 64-bit DLL; otherwise it would have been installed to C:\Program Files (x86)\
Navigate to the GAC from the command line: c:\Windows\assembly and look under GAC_32 vs. GAC_64. If you find it under GAC_64, you're trying to load the 64-bit DLL
HTH!
James

Categories