切换目标框架后不再加载 System.Data.SQLite.DLL [英] System.Data.SQLite.DLL no longer loads after switching target framework
问题描述
我不得不从 .net 4.5 切换到 .net 4.0,因为我的一些客户仍在使用 WinXP.现在,切换后,这是我得到的错误:
I had to switch from .net 4.5 to .net 4.0 because some of my customers still use WinXP. Now, after switching, this is the error I'm getting:
Could not load file or assembly 'System.Data.SQLite,
Version=1.0.66.0, Culturre-neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies.
An attempt was made to load a program with an incorrect format.
我一直无法找到解决方案,但这是我目前尝试的方法:
I haven't been able to find a solution for this, but here's what I tried so far:
- 切换回 4.5 - 无效
- 再次添加引用 - 无效
有人知道解决办法吗?
推荐答案
解决此问题的正确方法是从 http://system.data.sqlite.org.
The right way to fix this is to download an updated version of the SQLite library for your target framework from http://system.data.sqlite.org.
您使用的旧版 System.Data.SQLite 程序集是面向 .NET 2.0 的混合代码程序集..NET 4 下的默认策略是不允许加载此类程序集,但您可以通过在 MyApp.exe.config 文件中添加类似内容来明确允许它用于进程:
The older System.Data.SQLite assembly that you are using is a mixed code assembly that targets .NET 2.0. The default policy under .NET 4 is to not allow such assemblies to load, but you can explicitly allow it for a process by adding something like this into the MyApp.exe.config file:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
请注意,更改可能会破坏其他内容.
Note that the change can break other things though.
这个 StackOverflow 问题涵盖了类似的基础:
这篇关于切换目标框架后不再加载 System.Data.SQLite.DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!