Sergio and the sigil

Wrong .Net Version being loaded

Posted by Sergio on 2008-04-23

At work one application has this intermittend problem that started when the developer started to use telerik's r.a.d. web controls. Once in a while, for some (until today) unexplained reasons, the telerik controls would start throwing this error:

This control is complied for ASP.NET 1.x. 
Please use the ASP.NET 2.0 native version: RadTabStrip.Net2.dll 

For reasons that are not relevant for this post, the application runs under ASP.NET 1.1, not 2.0. What the error message reveals is that sometimes .Net v2.0 was being loaded first in that appDomain. Resetting the app and hitting /default.aspx would be enough to make that error go away. Until it happened again a few days after that.

The application developers and the webmaster spent quite a bit of time checking IIS settings, .Net settings, other apps in the same appPool. Everything seemed correct.

Today I joined the effort to get rid of that problem and as soon as I saw some .asp files mixed with the .aspx ones it struck me. "We don't happen to have VB6 code doing interop with .Net code, do you?". That's right, we did. There are valid reasons for this but again it doesn't matter here.

I immediately brought up Scott Hanselman's two posts where he describes a similar situation. Different symptom, but similar enough to help us.

Basically, if the very first page to be hit in the application is an .asp file that does interop with .Net, it will load the .Net runtime and the default behavior is to load the newest version possible, which is version 2.0 in our case. Once loaded, that version stays throughout the lifespan of the appDomain, leaving Telerik's code flipping.

There are a few possible solutions, which are discussed in Scott's posts and comments. In our case it boiled down to the following alternatives:

  1. Update the application to .Net 2.0 or 3.5, migrate the telerik assemblies, and get rid of the ASP/VB6 code: This is the ideal scenario. It is possible, but a little bit too time consuming in our case because of the amount of VB6 stuff there (old app, important app.) But if we could afford the time, that would be the best route to go.

  2. Update the application to .Net 2.0 or 3.5 and migrate the telerik assemblies: The next best thing considering the VB6 problem mentioned above.

  3. Just get rid of the ASP/VB6 code: This could work too. But it seems like too much work to keep supporting .Net 1.x.

  4. Try the ISAPI filter suggested by Scott here: Looks like a quick and effective solution. I would be willing to try it out. Unfortunately we have no C++ expertise in the house and the developer felt a little uncomfortable deploying this solution and creating one more dirty little secret in this already convoluted application.

  5. Bootstrap the classic ASP engine to start ASP.NET the right way: The idea here is to add a global.asa file to the application and use the Application_Start event to call a dummy ASP.NET url. The trick is to invoke some /dummy.aspx file via HTTP, like shown in this article.

They are leaning toward #5 (path of least resistance, I know) but the mid-term solution will be #2 followed by #1 (schedules and budget permitting.)

Anyway, I just wanted to share this in case someone is also tasked with maintaining their own version of the worst application in the world. Thanks Hanselman for making me look good once again.

Update: We chose to go with #5 until we can afford to do #1. The solution was to add the following to the global.asa file (remember those?). The file bootstrap.aspx can be an empty file. It's there only to, erm..., bootstrap ASP.NET.
<script language="vbscript" runat="server">
Sub Application_OnStart
	Dim url, inet, s, xmlhttp 
	'the url must be absolute (i.e. start with http://)
	url = "http://127.0.0.1/myapplication/bootstrap.aspx"

	Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
	xmlhttp.open "GET", url, false 
	xmlhttp.send "" 
	Set xmlhttp = Nothing 

End Sub
</script>