Parser Error Message: Could not load type

Have been wrestling with the ‘Parser Error Message: Could not load type’ error for the past day and a half.

Plenty of people on Google having the same problem – it turns out my version of this problem was caused by a rather subtle mistake.

The directory structure in my web site is as follows:
root
----dir1
--------app_directory

I had duly configured app_directory to be an Application Virtual Folder in IIS, and was getting the Parser error every time I opened the following URL:

http://www.mysite.com/dir1/app_directory/mypage.aspx

Before I got as far as the Parser Error Message, I was getting another message:

“It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level” – this error message pointed to the line:
<authentication mode=”none”>

I got round this error by removing the node from web.config – but really this was pointing to the solution.

The URL I should have been accessing was:
http://www.mysite.com/app_directory/mypage.aspx

I had gotten confused between the physical location of the folder on the server, and the path in the URL. Because the ‘dir1’ folder actually existed, IIS was still able to serve up the URL, including any test HTML pages I placed in the directory, but it did not consider it to be the Virtual Application Folder, and thus I was unknowingly breaking all sorts of rules.

Not sure what I could have done to spot this earlier – and I guess I take back what I was saying about Microsoft at midnight last night. Or some of it, anyway.