切换目标框架后不再加载 System.Data.SQLite.DLL [英] System.Data.SQLite.DLL no longer loads after switching target framework

查看:37
本文介绍了切换目标框架后不再加载 System.Data.SQLite.DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不从 .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:

  1. 切换回 4.5 - 无效
  2. 再次添加引用 - 无效

有人知道解决办法吗?

推荐答案

解决此问题的正确方法是从 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆