Tom Goff's .Net Musings

Tidbits of information regarding .Net, C#, and SQL Server.

The Catch with VS 2008 Multi-Targeting Support

leave a comment »

With the recent release of Visual Studio 2008, I have been trying to tinker with the new features when I have time. One of the features I especially like is the Multi-Targeting Support. You may have read about it before, but if not check out this blog. Using this feature, I could then benefit from the bug fixes, speed improvements, pretty interface changes, etc in Visual Studio 2008 with only minor changes to my applications. Unfortunately, there is a small catch.

If you read Scott Hanselman’s blog, then you may have read this entry. In order to install Visual Studio 2008, you obviously must install .Net 3.5 (which is all part of the Visual Studio setup). In order to install .Net 3.5, you must install .Net 3.0 SP1 and .Net 2.0 SP1. As Scott describes, there are new properties/methods that are added to the .Net 2.0 framework as part of SP1.

So if you develop an application that targets .Net 2.0 in Visual Studio 2008 and use one of the new methods or properties, then obviously your application will not run on a computer with .Net 2.0 RTM. Since the assembly versions from the RTM and SP1 are the same, your application will load the RTM assemblies and then throw an exception when it can’t find the required method or property. If you do not use any of the new properties or methods, then your application will run on a computer with .Net 2.0 RTM. In addition, you could simply apply the .Net 2.0 SP1 to the target computers.

There are a few ways to determine if a property, method, or class is new. The first is obviously the documentation. For example, the INotifyPropertyChanging interface is new to .Net 2.0 SP1 and you can see that .Net 2.0 is not included in the “Version Information” section at the bottom. The second option is to use a new optional FxCop rule (as described here) to flag items. Finally, you can test your assemblies on a computer with .Net 2.0 RTM. This last step really requires that you perform full test coverage of your assembly though.

Advertisements

Written by Tom

November 27, 2007 at 3:33 pm

Posted in .Net, C#, Gotcha, Visual Studio

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: