简体   繁体   English

如何在基于.net Framework 4.0的应用程序中使用System.Windows.Forms,Version = 2.0.0.0?

[英]How use System.Windows.Forms, Version=2.0.0.0 in a .net framework 4.0 based application?

in VS2010 write this code and run: 在VS2010中编写以下代码并运行:

=========== ===========

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"Microsoft.NET\Framework");
string pathV2 = Path.Combine(path, "v2.0.50727");
Assembly assembly = Assembly.Load(File.ReadAllBytes(Path.Combine(pathV2,  System.Windows.Forms.dll")));
Console.Write(assembly.Location); 

================= it will write out: C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Windows.Forms\\v4.0_4.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll ================它将写出: C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Windows.Forms\\v4.0_4.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll

so, how can I use System.Windows.Forms, Version=2.0.0.0 ? 因此,如何使用System.Windows.Forms, Version=2.0.0.0

thanks 谢谢

Why don't you just target .NET 3.5 SP1 (which uses the only System.Windows.Forms assembly)? 为什么不只针对.NET 3.5 SP1(使用唯一的System.Windows.Forms程序集)呢?

Or, if you're going to target .NET 4, then why are you trying to not target .NET 4? 或者,如果你要面向.NET 4,那么为什么你想面向.NET 4?

Edit 2: This isn't possible without creating a second assembly that targets .NET 3.5 or earlier. 编辑2:如果没有创建针对.NET 3.5或更早版本的第二个程序集,这是不可能的。

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

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