简体   繁体   中英

Can VS 2005 build C# for .NET 4?

我知道你可以构建一个较低版本的.NET,但是我可以针对.NET框架版本4构建一个项目吗?

No, each version of Visual Studio is only capable of targeting the framework it was released with and lower ones. (Leaving .NET 1.1 out of it...) So...

  • VS2005 can only compile against .NET 2.0 (and .NET 3.0 with some extensions, admittedly)
  • VS2008 can compile against .NET 2.0, .NET 3.0 and .NET 3.5
  • VS2010 can compile against .NET 2.0, .NET 3.0, .NET 3.5 and .NET 4.0

(And then there's client profiles, the Compact Framework, Silverlight etc.)

I think technically yes, but certainly not easily. You could customise the build process by hand to use the (freely available) compilers from the .NET 4 framework. You'd have to install .NET 4 by hand and then roll your own build scripts from scratch, if you wanted full integration, or hand-compile your projects from the command line.

It's worth remembering, though, that VS2005 wouldn't have IntelliSense support or compiler integration for .NET 4, so you're not going to have anything like a pleasant experience in the IDE. Notepad might be easier!

To be honest I'm not sure it's something I'd consider attempting!

正如其他人所说,答案是否定的。但是......根据你想要这样做的动机,你可以认为SharpDevelop是免费的,但没有相同的限制。

No.

You can however just get the .NET framework . That will give you the necessary assemblies and the compiler. While Visual Studio is great, it is not necessary.

VS is retrocompatible, but the opposite is false. This is a one way ticket. VS2005 is only compatible with .NET 2.0, and retrocompatible to 1.1 and 1.0.

Then, final answer is no. For example, VS2005 won't run on Vista unless you install Vista SP1.

No, VS2005 can only build against the .Net Framework 2.0. Support for multiple runtimes didn't show up until VS2008. You can use MSBee to build against 1.1 in 2005, but that is the closest you can get to multiple runtime targets.

If you use a seperate build tool, like NAnt , then you can target multiple framework versions (including Silverlight and Mono), assuming the code will compile against those frameworks.

No, not even for VS 2008 according to Scott Guthrie (who would certainly know):

There isn't any way to target .NET 4 from VS08 and use new features. Having said that, .NET4 is upwards comaptible with .NET 3.5 - so applications you build targeting .NET 3.5 with VS08 should work fine on top of .NET

http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx

Similar question here:

Can I develop for .NET Framework 4 in Visual Studio 2008?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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