Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add .Net3.5 dll into .Net2.0 project?

I have a dll which is based on .net 3.5 -- it uses internally for example Linq, but the exposed API is straightforward, no fancy stuff. Since C# generics are resolved at compile time I assume that for calling party all it counts is API (all public parts).

However when I try to use this dll from net2.0 project I get info, that the dll cannot be referenced because the dll or one of its dependencies requires a later version of .net framework.

I can install any .net version I want on target computer (when entire app is installed), but I cannot change .net version for the project itself.

So: how to solve this? When adding a C dll to this project I had no such problems, so are C# dlls self-contained or not?

like image 869
greenoldman Avatar asked May 05 '10 10:05

greenoldman


1 Answers

C# dlls need to have the .Net runtime to run as they are not compiled down to machine code. In this case the dll says it requires Net 3.5 so all your project will have to use 3.5 or higher.

To keep your project as Net 2.0 you would need to build another executable to contain the 3.5 DLL and communicate across separate processes.

The C DLL worked as it is compiled down to native code and does not require the .Net framework. (or at least not version higher than 2.0)

like image 187
mmmmmm Avatar answered Oct 10 '22 14:10

mmmmmm