1

What is the best practice for developing a shared class library in Visual Studio 2010 to be used by a .NET 3.5 app and a 4.0 app?

I could do it with separate project/solution files, one for 3.5 and one for 4.0 i.e. MyProject.3.5.csproj and MyProject.4.0.csproj but then I need to keep the files in sync. Is there a better way?

3
  • 4
    Do you need a version that is specifically 3.5 and one that is 4.0? 4.0 applications can load 3.5 assemblies just fine. Commented Oct 21, 2010 at 17:34
  • I was under the impression that if you only had .NET 4.0 installed you couldn't run .NET 3.5 assemblies because it uses a different CLR. Am I wrong? Commented Oct 21, 2010 at 19:47
  • For example, if you want to write code for Microsoft Systems Center Operations Manager, it says that you must target both .NET 3.5 and 4.x (see msdn.microsoft.com/en-us/library/hh329057.aspx, section entitled "Visual Studio Solution"). I don't see how to target more than one, do they mean you need 2 projects in the solution, one for each framework? Commented May 22, 2015 at 18:29

2 Answers 2

1

You can create a project in 3.5 framework and use it to create Dlls for to be used in either 3.5 or 4.0 projects

Sign up to request clarification or add additional context in comments.

1 Comment

Yes you can, although I'm still a little unclear as to how the 4.0 CLR actually handles this, but it appears you can configure 4.0 app (using app.config) to support older runtimes.
1

I think VS can have different projects targeting different versions of .NET Framework in the same Solution without trouble. Create an empty solution (it doesn't matter which framework version you use) then add the corresponding projects (here is where you choose the correct version of .NET framework for each of your projects).

If you have a solution already, you can change the targeting version of any of your projects in the solution by going into the project properties and changing the target version of .NET Framework there.

1 Comment

+1: Framework versions are indeed controlled at the project level, not the solution level. We have several solutions which link to 4.0/3.5/and even 2.0 projects depending on the situation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.