今天在C#下使用Sqlite时,导入System.Data.SQLite.DLL,运行后报了这个错误
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information
这好像是因为System.Data.SQLite.DLL是混合模式的CLR,.net会使用2.0去解析这个dll然后与.net 4.0的环境不兼容
我们需要的是配置一下App.config,让.net 用4.0去加载这个dll
将app.config中startup这段改成如下就可以了
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
本文介绍了如何解决在C#环境下使用System.Data.SQLite.DLL时遇到的.NET Framework版本兼容性问题。通过调整App.config文件中的启动设置,使应用程序能够正确地在.NET 4.0环境中加载并运行混合模式的Sqlite组件。
956

被折叠的 条评论
为什么被折叠?



