.NET exe not picking dll dependencies

2019-08-13 19:11发布

问题:

I have developed an EXE again :)

The problem is it has refernces of SQLite dll file so I included the file on the same path. Now in Windows 8 it is running fine, but in Windows 7 it is not

The error is

System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (Exception from HRESULT: 0x800736B1) File name: 'System.Data.SQLite, Version=1.0.90.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' ---> System.Runtime.InteropServices.COMException (0x800736B1): The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

I did everything I could but it is not running on Windows 7

It's a standalone EXE. No Setup.

EDIT: This is what application event log says

Activation context generation failed for "C:\System.Data.SQLite.dll". Dependent Assembly Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195" could not be found. Please use sxstrace.exe for detailed diagnosis.

回答1:

I think thats the reason as you mentioned, SQLLite is searching 64 bit dll!

Try to download 64 bit url and pack it with exe

You can download from here http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki



回答2:

side-by-side configuration is incorrect

That means Either:

  • One of your reference DLLS do not match your project target type
  • Or Your reference DLLS are of mixed target types

Solution:

  1. Make sure your Project is set to build to target x86 for x86 reference DLLs or target x64 for x64 reference DLLs, and the same for the .NET versions
  2. Make sure all your reference DLLs are either all x86 or all x64 versions and not x86 and x64, and the same for the .NET versions

If you are not sure you can use IlSpy to check by right clicking on the reference.



回答3:

Generally this error indicates that a dependent assembly is missing.

Activation context generation failed for "C:\System.Data.SQLite.dll". Dependent Assembly Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195" could not be found. Please use sxstrace.exe for detailed diagnosis.

This assembly is more commonly known as

Microsoft Visual C++ 2005 Redistributable Package (x86)

and can be downloaded from here.

But, often there is another cause. Today, for us, it was "Bit9 Security" which did not like us digitally signing the SQLite.dll assembly on our local machine and uploading the signed assembly to our server application folder with a different time stamp to the rest of the assemblies in the application folder.

The work around was to recompile the application, sign all the assemblies, upload and overwrite the existing application files.



标签: c# .net sqlite dll