Tuesday, May 16, 2006
« Utah SQL PASS Code Camp - May 31st, 2006... | Main | Resharper 2.0 Released Today »

If you're creating a Web Service and you run across an error that resembles this:

Server Error in '/MyVirtualDirectory' Application.

Parser Error
...
Parser Error Message: Could not create type 'xxx.MyWebService'.

Don't worry, it's not that difficult to fix.

First of all, make sure your website is indeed within a Virtual Directory running the proper version of ASP.NET.  This can be ascertained in IIS.

Barring that, make sure you have deployed your website's DLLs into the proper \bin directory.  I ran into this error because my virtual directory is actually housed within another virtual directory/site that had it's own assembly references and I had removed them in my web.config like this:

<compilation defaultLanguage="c#" debug="false">
   <assemblies>
      <clear />
   </assemblies>
</compilation>

Once you do that, you effectively lose reference to your own DLLs.  Simply add yours back, along with the others you need (Web Services will require System.Xml and System.Web.Services).

Your web.config file may resemble this for ASP.NET 1.1:

<compilation defaultLanguage="c#" debug="false">
   <assemblies>
      <clear />
      <add assembly="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
      <add assembly="System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null" />
      <add assembly="My web service dll here" />
   </assemblies>
</compilation>