Navya
Navya

Reputation: 35

how to add a .net 4.0 dll to a project running on dotnet 3.5

I have a class library build in .net framework 4.0. i want to add it to an old project build in .net framework 3.5 .. is there any way to do it other than upgrading the old project? also it will be helpful if you could tell me how to downgrade my dll to 3.5

Upvotes: 2

Views: 2882

Answers (2)

Rich Turner
Rich Turner

Reputation: 10984

Do you have the source to both the 4.0 DLL and the 3.5 project? If so, your can:

  1. Port & rebuild the 4.0 DLL to 3.5
  2. Port & rebuild your 3.5 project to .NET 4.0.
  3. Coerce your 3.5 project to run on the 4.0 CLR by modifying your app's config:
<configuration>
  <startup >
    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

If you choose option 3, be sure to test your code thoroughly as your code may reference API's that have changed behavior and/or API's and may result in runtime breakage that's hard to detect and fix.

Be sure to read the documentation covering the ability of .NET 4.0 apps to better handle components built for earlier versions of .NET.

It's perhaps wise to start preparing now for the future and re-factoring your code to push all your core business logic into .NET Portable Assemblies which will make it easier to reuse that code in Windows Desktop, Windows Metro-style apps, Windows Phone apps, Silverlight apps, XBox apps, etc.

HTH.

Upvotes: 1

Adam Ralph
Adam Ralph

Reputation: 29956

You won't be able to run the .NET 4.0 DLL in a .NET 3.5 process.

If you have the source code, then you can convert it to .NET 3.5 by changing the target framework of the project (either in Visual Studio or by hand). If the source code is relying on .NET 4.0 specific features then you will have to change it to work with .NET 3.5. Whether or not this is feasible depends on how heavily the code is relying on .NET 4.0 features and whether the same effect can be achieved using only .NET 3.5.

Upvotes: 2

Related Questions