views:

41

answers:

2

I have a basic server control that I've written using .NET 3.5. If I give that dll to someone who is running a .NET 2.0 application, will it work?

+1  A: 

Unless you are referencing any DLL's included in .NET 3.0 or 3.5 then yes it should work because the CLR versions are the same in .NET 2.0, 3.0, and 3.5. I believe there may have been minor changes to the 2.0 assemblies ("red bits") but I'll have to double check.

You can even just change the project properties in Visual Studio to target .NET 2.0 to be sure. If your app doesn't compile then it wouldn't have run on .NET 2.0 anyway.

Scott Hanselman has posted about .NET 2.0-3.5 differences.

Josh Einstein
Does the "Target Framework" setting in the project properties have any bearing on compatibility?
MJ Hufford
Yes, set this to 2.0 and Visual Studio will prevent you from using functionality not present in the 2.0 framework.
Josh Einstein
Yes, you're right: there were indeed minor changes to the 2.0 "red bits" in 3.x. Be warned, Visual Studio will NOT detect these when you set the Target Framework: it only prevents you using 3.x assemblies, not 3.x methods in 2.0 assemblies. I think there is a Code Analysis rule that will catch these though; also installing the 2.0 service packs updates the red bits to the 3.x levels.
itowlson
@itowlson, I can't find anything at the moment but weren't the red bits changes applied to a .NET 2.0 service pack? I honestly can't remember.
Josh Einstein
Josh: Yes, they were. So if MJ's customer has a fully SPed copy of 2.0 he'll be fine (from a "untraceable changes to red bits" point of view anyway \*grin\*).
itowlson
Gracias. The problem I was having was caused by...well...a typo. :-) Thanks for the info for the future!
MJ Hufford
A: 

The first thing you should do is try changing the Target Framework to 2.0 and see if your Server Control project still compiles (Right click on the project, choose Properties, then change the Target Framework to ".NET Framework 2.0" and choose "Yes" in the "Target Framework Change" dialog). If it still compiles you're off to a fairly good start. Now compile it, add it to a new web site and check to see if it works.

Most of the time you'll probably find that your control won't be using any 3.5 specific features, so once you've tried compiling it against 3.5 you'll be good to go!

Rob