views:

453

answers:

1

I know it's a bit close to Can I use .NET 4.0 beta in Visual Studio 2008?

But my question is a bit different. I have a project that now uses .NET 4.0 (target .NET Framework 4.0) in Visual Studio 2010. Is it possible to use the project compiled dlls in Visual Studio 2008? How?

I don't want to use .NET4.0 directly in Visual Studio 2008, only the compiled dlls with target .NET Framework 4.0 (this is how my question is different that what has been asked so far).

I know that I was able to use .NET3.5 in Visual Studio 2005. So why not .NET4.0 in Visual Studio 2008?

+2  A: 

.NET 3.5 didn't have new versions of mscorlib, System.dll etc - it had new assemblies, but the ones you could use from .NET 2 were the same.

.NET 4 introduces new versions of these core assemblies - and your built DLL will reference those new versions explicitly. Visual Studio 2008 doesn't know about those versions - or the CLR which goes with them.

If you want to use a library in Visual Studio 2008, you should target .NET 3.5 to start with.

Jon Skeet
Is it completely impossible to reference these new assemblies in Visual Studio 2008? Is it because Visual Studio 2008 itself is built on the old assemblies? Is a forward compatibility update is expected for Visual Studio 2008?
brickner
@brickner: It's because Visual Studio 2008 uses CLR v2, whereas .NET 4 requires CLR v4. Various things - including the debugger - need to understand the CLR details intimately. I wouldn't expect an update for VS2008, personally. As I say, the way to get round this is to target .NET 3.5 - or if you want to target .NET 4, update to 2010.
Jon Skeet
@Jon Skeet, thanks. The problem I'm having is targeting framework 3.5 in Visual Studio 2010 C++/CLI project. I have tried adding <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> and after getting C1001 <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences> but now I get a VS2010 crash. See http://stackoverflow.com/questions/2106163/target-net-3-5-c-cli-in-visual-studio-2010-beta-2Any solution for this problem? I only see two solutions - staying with Visual Studio 2008 or upgrading to .NET Framework 4.0 (this is why I've asked the question to begin with).
brickner
https://connect.microsoft.com/VisualStudio/feedback/details/560606/c1001-compiler-crash-on-c-cli-project-in-vs2010-when-target-framework-is-3-5
brickner
@brickner: Ah, it's C++ - I'm afraid I don't know anything about that side of things :(
Jon Skeet