Can you mix .NET framework Versions in a solution?

后端 未结 7 1181
遇见更好的自我
遇见更好的自我 2021-02-06 21:17

Our codebase where I work is .NET 2.0. For our new assembly/DLLs/web applications I would love to take advantage of what 3.5 has to offer.

Can one mix .NET frameworks(pe

相关标签:
7条回答
  • 2021-02-06 21:52

    You can use 2.0, 3.0 and 3.5 together according to: http://msdn.microsoft.com/en-us/library/bb383796(v=vs.90).aspx

    0 讨论(0)
  • 2021-02-06 21:52

    You cannot have .Net 1.1 assmeblies running in the same process as a .Net 2.0+ assembly - attempting to do so will produce a failure.

    With regards to IIS, this means that you cannot have .Net 1.1 sites / virtual directories running in the same application pool as .Net 2.0 and above sites - you need to create a separate app pool to keep the .Net 1.1 code running in a different process. (This can only be done in IIS 6.0 and above, i.e. not in Windows XP)

    However as nobugz says - .Net 2.0 through to .Net 3.5 all use the same CLR, and so different versions of .Net code can be mixed in the same assembly without worry - this also holds true for IIS (.Net 2.0 and .Net 3.5 code can happily co-exist in the same app pool)

    0 讨论(0)
  • 2021-02-06 21:53

    If you can wait for the new .NET 4.0 framework, you will be able to run dll's for each version side by side in the same process.

    0 讨论(0)
  • 2021-02-06 21:56

    This should not be an issue. .NET 2.0 RTM through .NET 3.5 SP2 all use the exact same version of the CLR. They only differ by the number of assemblies that are included. The assembly format is the same. Of course, if you do take advantage of an assembly that's only included with .NET 3.5, you must make sure that 3.5 is actually installed on the target machine. You'll find out quickly if it isn't.

    3.5 should already be on the machine if it has Windows Update enabled. If not, it takes a dozen or so minutes to get it on there.

    0 讨论(0)
  • 2021-02-06 22:00

    Yes you can do this in Visual Studio and it is called Multi-Targeting.

    Scott Guthrie has a great blog-entry on Multi-Targeting Support in Visual Studio.

    VS 2008 was the first release of Visual Studio that included multi-targeting support for .NET. What this meant was that you could use VS 2008 to create and edit not only .NET 3.5 projects, but also .NET 3.0 and .NET 2.0 projects as well. This allowed developers to more quickly upgrade and take advantage of new Visual Studio tooling features – without having to necessarily require the newer version of .NET to be installed on the clients and production servers running their applications.

    Cheers

    0 讨论(0)
  • 2021-02-06 22:05

    EDIT: I was wrong you can. You can go reference 3.+ assemblies in 2.0, because the CLR is the same. This will not be the case when going from 2.0/3.+ to 4.0 as there is a new version of the CLR.

    http://abdullin.com/how-to-use-net-35-syntax-and-compiler-features-for-net-20/

    0 讨论(0)
提交回复
热议问题