"Could not create type XXXX" when accessing a .asmx page on IIS 7.0

If you are using a Web Site project, you should be putting your codebehind GeocachingServer.asmx.cs in the ~/App_Code/ directory and pointing to that path in the .asmx

If that didn't work, you forgot to right click on your virtual directory and pick Convert to Application.

Although you should have created an application on that folder in the first place, instead of making it a virtual Directory. You should click Add Application when creating it.

IIS7 Convert to application


I have found a workaround solution: put the .asmx.cs code after the first line of the .asmx file and remove the CodeBehind attribute on the first line of the .asmx file.