简体   繁体   English

将应用程序从.net 4.0降级到3.5

[英]Downgrade an application from .net 4.0 to 3.5

I have been developing an application in VS2010 and compiling it for the .NET 4.0 as the target framework. 我一直在VS2010中开发一个应用程序,并将其编译为.NET 4.0作为目标框架。 After integrating a library into my application, I get the following error message when I try to compile: 将库集成到我的应用程序后,我在尝试编译时收到以下错误消息:

Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. 混合模式程序集是针对运行时的版本“v1.1.4322”构建的,如果没有其他配置信息,则无法在4.0运行时中加载。

The library works fine under .NET 3.5, but when I change my target framework to .NET 3.5, I get the following error for all my .resx files: 该库在.NET 3.5下工作正常,但是当我将目标框架更改为.NET 3.5时,我的所有.resx文件都出现以下错误:

Error 1 Object reference not set to an instance of an object. 错误1未将对象引用设置为对象的实例。

I tried ctrl-h Version=4.0.0.0 to Version=3.5.0.0 but that doesn't seem to work. 我试过ctrl-h Version = 4.0.0.0 to Version = 3.5.0.0但这似乎不起作用。 Is there anything I can do other that create a new application? 有什么我可以做的其他创建一个新的应用程序?

Open your .resx file with the XML editor instead of the resources editor, and search for System.Windows.Forms, Version=4.0.0.0 . 使用XML编辑器而不是资源编辑器打开.resx文件,然后搜索System.Windows.Forms, Version=4.0.0.0 There should be 2 instances of this string. 这个字符串应该有2个实例。 Replace 4.0.0.0 with 2.0.0.0 and save the file. 4.0.0.0替换为2.0.0.0并保存文件。 Your resources should work correctly now. 您的资源现在应该正常工作。

Note that you can also go back to .NET 4 and try to add the following to your App.config to allow older assemblies to run on the new runtime: 请注意,您还可以返回到.NET 4并尝试将以下内容添加到App.config中,以允许旧的程序集在新的运行时上运行:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

You should be able to make this work by configuration settings in app.Config. 您应该能够通过app.Config中的配置设置来完成这项工作。

Just add the useLegacyV2RuntimeActivationPolicy="true" flag to your appConfig in the startup section . 只需在启动部分的appConfig中添加useLegacyV2RuntimeActivationPolicy="true"标志即可。 This causes the .NET 4 runtime to handle older mixed-mode assemblies. 这会导致.NET 4运行时处理旧的混合模式程序集。

Open Properties of project. 打开项目的属性。 Then select the Resources. 然后选择资源。 Delete all resource images and insert them again. 删除所有资源图像并再次插入。 now compile it. 现在编译它。 Your project is working now.. :) 你的项目现在正在运作.. :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM