locked
Can I develop application in Visual studio 2010 using C# 5.0 RRS feed

  • Question

  • .net Framework 3.5 was followed by 3.0. on that sense we must be able to use the new language feature and .net framework 4.5 visual studio. I have this confusion. Do I have to buy Visual Studio 2012 in order to use the new framework?
    Tuesday, July 31, 2012 5:01 AM

Answers

  • svick is absolutely correct - but I thought I'd also try to be very clear about this - 

    Visual Studio 2010 will not let you develop using C# 5.  The new C# 5 language features are part of the compiler, and will be included in the Visual Studio 2012 compiler.  Even if you install .NET 4.5, this will not let you take advantage of the new features of the language (such as async/await), as these require a new compiler to use.

    If you want to use C# 5, you'll need VS 2012 (though the express edition will work, and is free.)


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Thursday, August 2, 2012 12:21 AM
    Moderator
  • You're confusing two different things: what framework is used for compilation and what framework is actually used for running the application.

    When compiling, so called reference assemblies are used. And VS 2010 doesn't work with .Net 4.5 reference assemblies, so you can't compile .Net 4.5 application using VS 2010.

    When running, if you have .Net 4.5 installed, .Net 4.5 assemblies are used for running both .Net 4.0 and .Net 4.5 applications. That's what it means that 4.5 will replace 4.0.

    What this means is that your 4.0 applications will benefit from bugfixes and performance improvements in 4.5, but you can't use the new features of 4.5 in your applications compiled in VS 2010.

    Installing .Net 4.5 doesn't overwrite the .Net 4.0 reference assemblies, so you will be still able to develop .Net 4.0 applications using VS 2010.

    Tuesday, July 31, 2012 8:06 AM
  • I'm not sure why are you confused, but yeah, you pretty much need to use VS 2012 to develop using C# 5.0.

    Although there are other possibilities:

    • Use some other IDE, like SharpDevelop, or Visual Studio Express 2012, when it's released.
    • Use VS 2010 with Async CTP. I wouldn't recommend this, because it means you would be using pre-release quality software.
    Tuesday, July 31, 2012 5:50 AM

All replies

  • I'm not sure why are you confused, but yeah, you pretty much need to use VS 2012 to develop using C# 5.0.

    Although there are other possibilities:

    • Use some other IDE, like SharpDevelop, or Visual Studio Express 2012, when it's released.
    • Use VS 2010 with Async CTP. I wouldn't recommend this, because it means you would be using pre-release quality software.
    Tuesday, July 31, 2012 5:50 AM
  • Thanks for your answer.

    My question is is it possible to use .net Framework 4.5 inside visual studio 2010? The cause of the confusion is I read somewhere that 4.5 will not be running side by side with 4.0 instead it will replace 4.0.

    http://blogs.msdn.com/b/dotnet/archive/2011/09/26/compatibility-of-net-framework-4-5.aspx?CommentPosted=true#commentmessage

    If I am installing Visual Studio 2012 express edition for example it probably overwrite the 4.0 framework and how I will be able to develop using VS 2010 then?

    Tuesday, July 31, 2012 7:56 AM
  • You're confusing two different things: what framework is used for compilation and what framework is actually used for running the application.

    When compiling, so called reference assemblies are used. And VS 2010 doesn't work with .Net 4.5 reference assemblies, so you can't compile .Net 4.5 application using VS 2010.

    When running, if you have .Net 4.5 installed, .Net 4.5 assemblies are used for running both .Net 4.0 and .Net 4.5 applications. That's what it means that 4.5 will replace 4.0.

    What this means is that your 4.0 applications will benefit from bugfixes and performance improvements in 4.5, but you can't use the new features of 4.5 in your applications compiled in VS 2010.

    Installing .Net 4.5 doesn't overwrite the .Net 4.0 reference assemblies, so you will be still able to develop .Net 4.0 applications using VS 2010.

    Tuesday, July 31, 2012 8:06 AM
  • svick is absolutely correct - but I thought I'd also try to be very clear about this - 

    Visual Studio 2010 will not let you develop using C# 5.  The new C# 5 language features are part of the compiler, and will be included in the Visual Studio 2012 compiler.  Even if you install .NET 4.5, this will not let you take advantage of the new features of the language (such as async/await), as these require a new compiler to use.

    If you want to use C# 5, you'll need VS 2012 (though the express edition will work, and is free.)


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Thursday, August 2, 2012 12:21 AM
    Moderator
  • you pretty much need to use VS 2012 to develop using C# 5.0.

    Unfortunately vs2012 UI sucks. So the only option is to stick with vs2010 and CTP.

    If only the CTP setup would work...


    • Edited by LinoB Wednesday, August 22, 2012 3:54 PM
    Wednesday, August 22, 2012 3:54 PM
  • If you want to use C# 5, you'll need VS 2012 (though the express edition will work, and is free.)
    ....and has the same crap UI of the paid version so it is not a viable option.

    • Edited by LinoB Wednesday, August 22, 2012 3:56 PM
    Wednesday, August 22, 2012 3:56 PM
  • you pretty much need to use VS 2012 to develop using C# 5.0.

    Unfortunately vs2012 UI sucks. So the only option is to stick with vs2010 and CTP.

    If only the CTP setup would work...


    If you're going to do that, I would recommend not relying on the async/await language features - the CTP was just that, a "tech preview".  Even though it now allows commercial redistribution, the download page states:

    "This license does not constitute encouragement for you to use the CTP for your production code. The CTP remains an unsupported and use-at-your-own-risk Technology Preview. "

    You're putting yourself at risk to just have everything break randomly one day if there's an update for VS, or the framework, etc.  If you want to use the new features, now that they're out, getting used to the new UI is probably the best option...


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Wednesday, August 22, 2012 5:33 PM
    Moderator
  • you pretty much need to use VS 2012 to develop using C# 5.0.

    Unfortunately vs2012 UI sucks. So the only option is to stick with vs2010 and CTP.

    If only the CTP setup would work...


    Yes that is clearly the ONLY option.  Have you considered sacking up and getting used to it, perhaps even enjoying some of the myriad other features it provides?  There is an app for curmudgeonly developers who hate change - its called VI
    Tuesday, October 23, 2012 1:54 PM