Inetinfo.exe Crashes On Certain Web Project

21 12 2006

Great. Just spent a nice two hours figuring out why inetinfo.exe (the IIS process) crashes when I open a certain web project.

I went Googling, and after a while I found a KB article describing the exact problem I had, even with the exact same event ID’s in the system event log. But I couldn’t find a download, and even if I did, it was Windows Server 2003 only. Had something to do with an exploit in the SMTP service. Anyway, that didn’t help me.

So I tried something totally not logical: opening a different web application in my IDE. And bingo: it opened just fine. So maybe the configuration of the ‘bad’ project was defunct? -No. And so it should be, I hadn’t tinkered with it for a long time, so why would it suddenly not work anymore. (As the rest of this story will show, I forgot to check one setting.)

Then, my penny dropped (“mijne frang viel” -Flemish expression): I recently added another web site in IIS, besides the default one. This had to be done for another, single, project that used .NET 2.0. And indeed, the configuration for the ‘bad’ project was wrong: it said to use .NET 2.0, where it was previously using 1.1.

I suppose switching between the two sites fires a bug in IIS, overwriting some configurations…? I don’t know, but I’m fairly sure the config for the ‘bad’ project has stayed the same ever since it was created…

Anyhoo, another experience richer I guess.

Technorati Tags: , , ,





Type Casting Performance in .NET

21 09 2006

[ as taken from MSDN © Microsoft Corporation. All rights reserved. ]

The DirectCast keyword introduces a type conversion operation. You use it the same way you use the CType keyword, as the following example shows:

Dim Q As Object = 2.37		' Requires Option Strict to be Off.
Dim I As Integer = CType(Q, Integer)	' Succeeds.
Dim J As Integer = DirectCast(Q, Integer)	' Fails.

Both keywords take an expression to be converted as the first argument, and the type to convert it to as the second argument. Both conversions fail if there is no conversion defined between the data type of the expression and the data type specified as the second argument.

The difference between the two keywords is that CType succeeds as long as there is a valid conversion defined between the expression and the type, whereas DirectCast requires the run-time type of an object variable to be the same as the specified type.

In the preceding example, the run-time type of Q is Double. CType succeeds because Double can be converted to Integer, but DirectCast fails because the run-time type of Q is not already Integer. DirectCast throws an InvalidCastException error if the argument types do not match.

If the specified type and the run-time type of the expression are the same, however, the run-time performance of DirectCast is better than that of CType.

TechnoratiTechnorati Tags: , , ,





Visual Studio 2003 Web Forms Designer Error with Page Inheritance

31 03 2006

When you use VS2003, and you are working on a project that uses page inheritance (replacing the standard System.Web.UI.Page by a BasePage class of your own), you probably have seen the following error when double-clicking an aspx page: “The file could not be loaded into Web Forms Designer” and some other blablabla…

I know of some workarounds, and this guy Tobin Harris [ tobinharris.com ] has summed them up all nicely on one page [ tobinharris.com ].

They are not a guaranteed solution however, but in many cases one of the workarounds might help you. If not the case, I read some other workaround somewhere on some site that I can’t remember :)   Here we go ! [ dotnet.org.za ]

It states that the problem is when your custom BasePage class is declared abstract, and this way, the Forms Designer can’t instantiate any of the methods, and thus is unable to build a view of the web page.
The workaround consisted of writing extra code like this:

#if(DEBUG)
public class BasePage : System.Web.UI.Page
#else
public abstract class BasePage : System.Web.UI.Page
#endif
{
#if(DEBUG)
public virtual void method1()
{
throw new NotImplementedException();
}
#else
public abstract void method1()
#endif
}

If you’re developing, you’re in debug mode, and that’s the only time you’ll need the Forms Designer. if you need that crap at all, cause basically it does more bad then good, but it also triggers and fires the annoying error message when directly viewing the HTML code. When deployed, you’ll mostly use a release build, and that’s when your BasePage class will be declared abstract, like it should be.

TechnoratiTechnorati Tags: , , , , ,