我有一个项目,我想在其中使用一些。net 4.0的功能,但核心要求是我可以使用System.Data.SQLite框架,它是针对2.X编译的。我看到提到这是可能的,比如这里接受的答案,但我不知道如何实现这一点。
当我只是试图运行我的4.0项目,同时引用2。我得到:
混合模式程序集是根据运行时版本“v2.0.50727”构建的 并且不能在4.0运行时加载 配置信息。
需要什么“额外配置”?
我有一个项目,我想在其中使用一些。net 4.0的功能,但核心要求是我可以使用System.Data.SQLite框架,它是针对2.X编译的。我看到提到这是可能的,比如这里接受的答案,但我不知道如何实现这一点。
当我只是试图运行我的4.0项目,同时引用2。我得到:
混合模式程序集是根据运行时版本“v2.0.50727”构建的 并且不能在4.0运行时加载 配置信息。
需要什么“额外配置”?
当前回答
在将一些代码从VS 2008迁移到VS 2010时,我也遇到了类似的问题 修改App.config文件为我解决了这个问题。
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"
sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
</configuration>
其他回答
为了使用CLR 2.0混合模式程序集,您需要修改App.Config文件以包括:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
关键是useLegacyV2RuntimeActivationPolicy标志。这将导致CLR使用最新版本(4.0)加载混合模式程序集。没有这一点,它就不会起作用。
注意,这只对混合模式(c++ /CLI)程序集有影响。你可以加载所有托管的clr2程序集,而不需要在app.config中指定。
经过3-4小时的谷歌搜索,我找到了解决这个问题的方法。我添加了以下内容
<startup selegacyv2runtimeactivationpolicy="true">
<supportedruntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>
If this doesn't solve your problem then--> In the Project References Right Click on DLL where you getting error --> Select Properties--> Check the Run-time Version --> If it is v2.0.50727 then we know the problem. The Problem is :- you are having 2.0 Version of respective DLL. Solution is:- You can delete the respective DLL from the Project references and then download the latest version of DLL's from the corresponding website and add the reference of the latest version DLL reference then it will work.
当我们切换到Visual Studio 2015时,我遇到了这个问题。上面的答案对我们都没用。最后,我们通过将以下配置文件添加到机器上的所有sgen.exe可执行文件中来让它工作
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>
</configuration>
特别是在这个位置,即使我们的目标是。net 4.0:
C:\Program Files (x86)\Microsoft sdk \Windows\v10.0A\bin\NETFX 4.6 Tools
我使用这样的配置:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v2.0"/>
<supportedRuntime version="v4.0"/>
</startup>
为我工作
我也遇到过同样的错误,花了很长时间将建议的启动语句添加到我的解决方案中的各种配置文件中,试图隔离框架不匹配。毫无效果。我还向XML模式添加了启动信息。这也无济于事。查看导致问题的实际文件(只会说它被“移动或删除”),发现它实际上是许可编译器(LC)。
删除有问题的license。Licx文件似乎已经解决了这个问题。