您的位置:首页 > 产品设计 > UI/UE

C#中遇到dll与.net 4.0不兼容,Mixed mode assembly is built against version 'v2.0.50727' 的解决办法

2015-07-06 15:27 429 查看
今天在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#