Why I think some people shouldn't use VSNET 2003.
Additional Note:
I've changed the title of this article. The title is a hint from Robert. While I think blogging is about ventilating personal opinions, I do not feel it's my duty to bring Scott and this site (because the blogs are in the main feed) in trouble.
I do however find it pretty weird that people complain about this article but do not complain directly to me, by email f.e. I know I choose titles and article topics sometimes on the 'edge' of what can be tolerated. I learned that when I was a newseditor. Bad habbits never die, they say. The comments on this blog showed there are some solutions but they're all not that easy (for the customer or for the developer).
As a final remark, for Microsoft: a developer has to make two choices: which .NET version to target and which IDE version to choose. With Visual Studio.NET I have one choice: the .NET target is also implying the IDE version. I can't force my customers to shell out money to upgrade to VS.NET 2003, just because I think it's nice to target .NET 1.1. These two things: platform and IDE, should be separated. I can still develop software for Windows98 in VS.NET 2003, and I can also develop win32 software for Windows2003 in VS.NET 2002. Let that kind of freedom also be a choice for .NET developers. Thanks.
This morning it hit me: upgrading to Visual Studio.NET 2003 for .NET development of class libraries and controls is a bad choice when you are going to sell those class libraries and controls. I'll try to describe what drove me to this conclusion.
Visual Studio.NET 2003 offers great new features, for me the best are the faster compiler and the great new intellisense features. It also has a big caveat: it will use .NET 1.1 when compiling your code. This means that any library or control you develop in Visual Studio.NET 2003 and which relies on even a single .NET assembly, f.e. System.Data, will target .NET 1.1. Visual Studio.NET 2002 targets .NET 1.0. If you compile your code with Visual Studio.NET 2002, your code is requesting the .NET 1.0 versions of the libraries you reference.
Because of the new features in Visual Studio.NET 2003 (and don't forget the huge amount of bugfixes, still not available for Visual Studio.NET 2002), developers who can, want to upgrade to this new Visual Studio.NET version a.s.a.p. Microsoft offers side-by-side installation of this new version with the 2002 version, so it is a no-brainer, right? No. It's a big mistake, and this article is ment to warn any software vendor who wants to release assemblies for developers of .NET applications: do NOT, I repeat, do NOT upgrade to Visual Studio.NET 2003, because it will seriously hurt your customer, if he can use your code at all. Only consider an upgrade if you are totally sure your customers use .NET 1.1 and / or you have to because you are using .NET 1.1 features.
Let's investigate a real-life situation:
The problem
Within a few months I hope to release a generator/framework which will generate code which targets the accompanying framework. This framework is written in C# and is pre-compiled, it comes in the form of a couple of assemblies. You can also pick a situation where a developer writes a control-library in C# or VB.NET and sells it to other developers for usage in their products, same problem.
When you, as an ISV, write your code in Visual Studio.NET 2002, it will be compiled with .NET 1.0 in mind. This means: your class library DLL will run on any system with .NET 1.0 installed, or .NET 1.1 installed: when both are installed, it will pick .NET 1.0, if .NET 1.0 is installed it will pick .NET 1.0 and when .NET 1.1 is installed, it will pick .NET 1.1. This also means that any developer can buy your library/framework: if they use Visual Studio.NET 2002 or 2003, it doesn't matter, the assembly will run OK.
The situation changes dramatically when you, as an ISV, switch to Visual Studio.NET 2003. Your class library DLL will from then on target .NET 1.1, even if you do not use .NET 1.1 features. This also means that customers who buy your library and who use Visual Studio.NET 2002 will run into problems, because their code is compiled against .NET 1.0 and will not run, simply because the bought assembly requires .NET 1.1 assemblies which are not available. Errors like this will appear at the customers machine:
FrameworkTester.exe is a testapplication compiled on a box with .NET 1.0. The error-causing method is in a library compiled on a box with .NET 1.1 (using Visual Studio.NET 2003) and referenced during the compile of the FrameworkTester testapplication. As the error shows, the assembly compiled with Visual Studio.NET 2003 requires System.Data v1.0.5000.0, which is .NET 1.1.H:\Temp\dotnet test>FrameworkTester.exe Unhandled Exception: System.IO.FileNotFoundException:
File or assembly name System.Data, or one of its dependencies, was not
found. File name: "System.Data" at SD.NorthwindTest.DaoClasses.CustomerDAO.FetchCustomer(String customerID) ... Fusion log follows: === Pre-bind state information === LOG: DisplayName = System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken = b77a5c561934e089 (Fully-specified) LOG: Appbase = H:\Temp\dotnet test\ LOG: Initial PrivatePath = NULL Calling assembly : SD.NorthwindTest, Version=1.0.1235.22288,
Culture=neutral, PublicKeyToken=null. ...
The customer who runs Visual Studio.NET 2002 has now a big problem with your software: he can't use the assembly, unless he adds a long list of cryptic assemblyBinding tags to the config file of his application, and this is a cumbersome job to say the least. These assemblyBinding tags are automatically added in Visual Studio.NET 2003, when you specify .NET 1.0 as a supported platform for your application. A user of Visual Studio.NET 2002 doesn't have this functionality.
There are no figures of how many developers are on .NET 1.1 / Visual Studio.NET 2003 at the moment. Fact is that a very large part of the current .NET developers have .NET 1.0 on their machines and are most likely compiling against this platform. If you want to sell your software to developers, thus the developers in this large group, you shouldn't upgrade to Visual Studio.NET 2003 to avoid the platform conflicts and the resulting support hell that follows this. ISV's should compile using .NET 1.0 to be sure their customers can use the software they bought with the IDE they currently have: be it Visual Studio.NET 2002 or 2003.
What's causing this mess anyway?
The reason people have to jump through these hoops is the hard-wiring of the target platform in the IDE used. You can't target .NET 1.1 assemblies in Visual Studio.NET 2002 and you can't target .NET 1.0 assemblies in Visual Studio.NET 2003. This means that the choice which editor (!) you want to use for the source-text (!) is automatically also the choice which platform you are going to target.
Is there a solution?
Well... it would be very nice if I could set the target platform for the compiler in Visual Studio.NET myself, so I can benefit from the editor enhancements plus target older platforms so I can be sure all customers of my library will be able to use it in their applications no matter which version of Visual Studio.NET they use. However, this is not possible nor will it be possible. Microsoft decided it would be nice if developers get scr*wed over when they buy Visual Studio.NET, so here we are. Then there is the phenomenon Publisher Policy File. Microsoft states in the MSDN that you should be careful with these files and only release them when your application requires them. And how to use them in this situation? It probably requires a policy file for the .NET framework so all assemblies are redirected to the .NET 1.0 versions when a .NET 1.1 assembly requests a 1.1 version. Does anyone know? I couldn't find any information about this matter related to the backwards compatibility issue.
The best workaround is to supply a list of assemblyBinding tags with your assembly which then have to be included in the app.config file of the exe file compiled with .NET 1.0. This then redirects any requests from your .NET 1.1 targeting assembly to the .NET 1.0 assemblies. Did you know this? I didn't for sure. Is Microsoft supplying information about this? Not at all. Only upwards compatibility issues and information about side-by-side execution which will not work. See this article.
Oh, before you think: "but then I'll keep both Visual Studio.NET versions side by side on my machine!"... you can't open your projects in Visual Studio.NET 2002 after you opened them in Visual Studio.NET 2003. They get converted and you can't convert them back (you can, but it's messy). So a simple recompile using another Visual Studio.NET version is not possible.
If someone has a solution for this which works, please post it in the comments. I've tested it on a machine with solely .NET 1.0 installed and the only way I could run a .NET 1.0 compiled .exe which uses .NET 1.1 assemblies (i.e. bought assemblies) on the .NET 1.0 machine was using the assemblyBinding tags in the .config file. (I copied them over from the Visual Studio.NET 2003 version of the config file which contained these tags generated by Visual Studio.NET 2003).
I'm seriously considering going back to Visual Studio.NET 2002. It sucks, but I have no choice.