One of the applications I develop is a .NET 1.1 Windows Forms application used by more than 5000 users and critical for the business.
Being a complex and critical application, porting it to the 2.0 runtime just because it was not an option because it would mean installing the new runtime and framework on the stable environment of the workstations (Windows XP) and test fully the application. That was not an option.
As time went by, a developer received a brand new laptop with Windows Vista. Since he only needed ,NET 2.0 for his developments, he never installed .NET 1.1.
Another developer on my team had already tried to port the application to .NET 2.0 and run into some issues:
The main component of this application is the Web Browser Control
. This control derives from AxHost
, which changed going from 1.1 to 2.0 and needed major changes to compile for the 2.0 framework.
Another change was that mixing synchronous and asynchronous calls is not allowed in the 2.0 framework and we had, at least, one of those in our use of HttpWebRequest
The .NET 2.0 runtime and frameworks were developed to be highly compatible with applications written and compiled to the 1.1 runtime and frameworks. In fact, some of the changes were just applying the ObsoleteAttribute set to throw a compiler error when used, which doesn’t prevent its use by already compiled assemblies. This was the case of the WebBrowserControl/AxHost and just using the assembly compiled for .NET 1.1 would probably run fine. And it did.
The synchronous/asynchronous was also very easy to fix. All it took was changing this:
And it all worked as if it was running on .NET 1.1.
But that’s not the end of it. Latter came a requirement to use, in one of the web pages that ran in the web browser control, an ActiveX component developed in .NET 2.0.
But that time, the 2.0 runtime and framework were already installed on the workstations.
But how would we force the application to run in the 2.0 runtime if the 1.1 runtime was still there?
As simple as adding this to the configuration file (App.config):
<requiredRuntime version="v2.0.50727" safemode="true"/>