Click here to Skip to main content
Licence CPOL
First Posted 13 Apr 2010
Views 3,629
Bookmarked 3 times

Running .NET 1.1 Applications on .NET 2.0

By | 13 Apr 2010 | Technical Blog
Running .NET 1.1 Applications on .NET 2.0
A Technical Blog article. View original blog here.[^]

One of the applications I developed is a .NET 1.1 Windows Forms application used by more than 5000 users and is critical for the business.

Being a complex and critical application, porting it to the 2.0 runtime just because it was not an option, it would mean installing the new runtime and framework on the stable environment of the workstations (Windows XP) and fully test 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/HttpWebResponse.

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:

request.GetRequestStream()

into this:

request.EndGetRequestStream(response.BeginGetRequestStream(null, null))

And it all worked as if it was running on .NET 1.1.

But that’s not the end of it. Later 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.

How would we force the application to run in the 2.0 runtime if the 1.1 runtime was still there?

It was as simple as adding this to the configuration file (App.config):

<configuration>
  <startup>
    <requiredRuntime version="v2.0.50727" safemode="true"/>
  </startup>
</configuration>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Paulo Morgado

Software Developer (Senior)
Paulo Morgado
Portugal Portugal

Member

About Paulo Morgado

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionDoubt about changing version Pinmemberchisclas20:56 4 Apr '11  
AnswerRe: Doubt about changing version PinmemberPaulo Morgado14:13 5 Apr '11  
GeneralRe: Doubt about changing version Pinmemberchisclas20:30 5 Apr '11  
GeneralRe: Doubt about changing version PinmemberPaulo Morgado23:23 5 Apr '11  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 13 Apr 2010
Article Copyright 2010 by Paulo Morgado
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid