简体   繁体   English

.NET exe不选择dll依赖项

[英].NET exe not picking dll dependencies

I have developed an EXE again :) 我又开发了一个EXE :)

The problem is it has refernces of SQLite dll file so I included the file on the same path. 问题是它具有SQLite dll文件的引用,因此我在同一路径中包含了该文件。 Now in Windows 8 it is running fine, but in Windows 7 it is not 现在在Windows 8中可以正常运行,但在Windows 7中则不能

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. System.IO.FileLoadException:无法加载文件或程序集'System.Data.SQLite,版本= 1.0.90.0,文化=中性,PublicKeyToken = db937bc2d44ff139'或其依赖项之一。 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. 请查看应用程序事件日志或使用命令行sxstrace.exe工具以获取更多详细信息。 (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. (来自HRESULT的异常:0x800736B1)文件名:'System.Data.SQLite,版本= 1.0.90.0,文化=中性,PublicKeyToken = db937bc2d44ff139'---> System.Runtime.InteropServices.COMException(0x800736B1):应用程序失败由于其并行配置不正确而无法启动。 Please see the application event log or use the command-line sxstrace.exe tool for more detail. 请查看应用程序事件日志或使用命令行sxstrace.exe工具以获取更多详细信息。

I did everything I could but it is not running on Windows 7 我已尽我所能,但它无法在Windows 7上运行

It's a standalone EXE. 这是一个独立的EXE。 No Setup. 没有设置。

EDIT: This is what application event log says 编辑:这就是应用程序事件日志所说的

Activation context generation failed for "C:\\System.Data.SQLite.dll". “ 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. 找不到相关组件Microsoft.VC80.CRT,processorArchitecture =“ x86”,publicKeyToken =“ 1fc8b3b9a1e18e3b”,type =“ win32”,version =“ 8.0.50727.6195”。 Please use sxstrace.exe for detailed diagnosis. 请使用sxstrace.exe进行详细诊断。

I think thats the reason as you mentioned, SQLLite is searching 64 bit dll! 我认为这就是您提到的原因,SQLLite正在搜索64位dll!

Try to download 64 bit url and pack it with exe 尝试下载64位url并与exe打包

You can download from here http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki 您可以从此处下载http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

side-by-side configuration is incorrect 并行配置不正确

That means Either: 这意味着:

  • One of your reference DLLS do not match your project target type 您的参考DLLS之一与您的项目目标类型不匹配
  • Or Your reference DLLS are of mixed target types 或者您的参考DLLS是混合目标类型

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 确保将Project设置为针对x86参考DLL构建为目标x86或针对x64参考DLL构建为目标x64,对于.NET版本相同
  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 确保所有参考DLL都是x86或所有x64版本,而不是x86和x64,并且.NET版本相同

If you are not sure you can use IlSpy to check by right clicking on the reference. 如果不确定,可以通过右键单击参考使用IlSpy进行检查。

Generally this error indicates that a dependent assembly is missing. 通常,此错误表示缺少依赖程序集。

Activation context generation failed for "C:\\System.Data.SQLite.dll". “ 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 . 依赖大会 Microsoft.VC80.CRT,ProcessorArchitecture用于= “86”,公钥= “1fc8b3b9a1e18e3b”,键入= “win32的”版本= “8.0.50727.6195” 无法被发现 Please use sxstrace.exe for detailed diagnosis. 请使用sxstrace.exe进行详细诊断。

This assembly is more commonly known as 该程序集通常称为

Microsoft Visual C++ 2005 Redistributable Package (x86) Microsoft Visual C ++ 2005可再发行组件包(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. 今天,对我们而言,正是“ Bit9安全性”不像我们那样对本地计算机上的SQLite.dll程序集进行数字签名,然后将签名的程序集上载到服务器应用程序文件夹中,而时间戳记与其他程序集中的其余程序集不同。应用程序文件夹。

The work around was to recompile the application, sign all the assemblies, upload and overwrite the existing application files. 解决方法是重新编译应用程序,签名所有程序集,上载并覆盖现有的应用程序文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM