I would like to be able to use .NET 3.5 types in an application based on .NET 2.0.
Basically we don’t have deployed .NET 3.5 libraries in desktops but we need to use some classes from there. Any ideas how this is possible ?
Thanks,
Marios
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This question got me wondering, so I dug into it a bit.
The answer to your question depends on how many dependencies you have on the new frameworks, and how much hacking you are willing to do.
The real best answer is to bite the bullet and install the necessary framework. However, if you need to just distribute a single assembly from .net 3.0 it may be possible. I’m pretty sure, requiring an assembly from 3.5 will require installing 3.0. At that point, you have nothing to gain by not installing 3.5.
Here’s the hacking I did to make an assembly from 3.0 work from 2.0:
Hack # 1
Add the reference to the required 3.0. Visual Studio should complain. Unload the project and edit the project file. Remove this line from the xml and reload the project.
Visual Studio will happily compile and run with this assembly now.
Hack # 2
Change the copy local property in the assembly references list to true.
Hack # 3 (Ugliest hack)
Modify the machine config to add the config section for the required assembly. This may or may not be required, depending on the assembly you are pulling in. In my test, I referenced the System.Runtime.Serialization assembly and needed to copy this section from the machine.config on my 3.5 machine to my 2.0 machine.
Once I did that, the following code ran just fine on my .net 2.0 box.
…again, I’m not recommending this. But, it may be possible to bend the rules if you are really desperate.