我有一个.NET 4应用程序,它由app和两个类库组成。全部使用对System.Data.SQLite的引用。我正在使用xite版本的SQLite,我的所有程序集都设置为x86。
在某些机器上,当我尝试在使用SQLite的应用程序中执行某些操作时,我得到一个未处理的异常:
无法加载文件或程序集'System.Data.SQLite,Version = 1.0.79.0, Culture = neutral,PublicKeyToken = db937bc2d44ff139'或其中一个 依赖。尝试加载程序不正确 格式。
我的智慧结束了,因为我在x86和x64中尝试过.NET 3.5和.NET 4 SQLite DLL,但我得到了同样的错误。我在四台机器上测试过。以下工作正常:
以下抛出异常:
如果是架构问题,我希望运行在Win7 x64上的XP Mode也可以运行,但事实并非如此。此外,没有任何test.exe
文件包含在VMWare中的SQLite捆绑包,这让我觉得缺少了一些东西。
我在XP模式下在机器上运行FUSLOGVW,这是System.Data.SQLite的条目:
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Documents and Settings\XPMUser\Desktop\Release\ChickenPing.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = VIRTUALXP-92688\XPMUser
LOG: DisplayName = System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
(Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/XPMUser/Desktop/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ChickenPing.exe
Calling assembly : ChickenPing.DAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Documents and Settings\XPMUser\Desktop\Release\ChickenPing.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Documents and Settings/XPMUser/Desktop/Release/System.Data.SQLite.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Documents and Settings\XPMUser\Desktop\Release\System.Data.SQLite.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: System.Data.SQLite, Version=1.0.79.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: Binding succeeds. Returns assembly from C:\Documents and Settings\XPMUser\Desktop\Release\System.Data.SQLite.dll.
LOG: Assembly is loaded in default load context.
哪个表示成功,但仍然会发生未处理的异常?
答案 0 :(得分:2)
追踪这一点有些模糊。事实证明,需要VC ++ 2010可再发行的运行时。据我所知,System.Data.SQLite从来没有过这种依赖性,或者至少我从未意识到这一点。
答案 1 :(得分:2)
作为当前接受的答案的一种附录:它们实际上生成了静态链接的二进制文件,现在将VC redist直接编译到没有这种依赖关系的DLL中(因为它静态链接到DLL中)。 / p>
答案 2 :(得分:1)
您的应用程序是否明确编译为 x86 ?
如果您的应用程序是针对这两种体系结构编译的,那么它将在 x64 计算机上使用 x64 部分并调用 x86 dll - >这会引起你的异常...