IIS 7 and Above
Parser error: Could not Create Type Webservice
Last post May 18, 2012 12:23 PM by rishi76
Mar 30, 2010 05:00 AM|jpnuser|LINK
I've just started using IIS7 and have created my first C#-based webservice. It's been a lot of fun learning new stuff and working through all the problem on my own. However, I've finally hit something I just can't get past. When I run my webservice on
my local environment (Visual Studio 2008), My webservice runs fine and I can use it very well. When I install it on my IIS7.0 machine, I get a "Parser Error: could not create type 'WebService2.Service1' ".
In order to break the problem down to its simplest form, I created a dummy application. Here are the steps I took and the code that exists:
1.) Created a folder named c:\inetpub\wwwroot\dumbtest and c:\inetpub\wwwroot\dumbtest\bin
2.) Copied a file named Service1.asmx.cs and Service1.asmx to c:\inetpub\wwwroot\dumbtest\ and the contents of that are listed at the end of this post.
3.) Copied my compiled DLL (Webservice2.dll) to c:\inetpub\wwwroot\dumbtest\bin
5.) I go to http://localhost/dumbtest/Service1.asmx, and I get the Parser Error "Could not create type Webservice" Line 1 etc etc etc.(at the moment I'm running IE on the IIS server itself, thus the usage of localhost)
6.) Checked everything including spelling and capitalization .... as a result of my IIS changes, a simple Web.config file was created automatically by IIS7.0:
<?xml version="1.0" encoding="UTF-8"?>
<directoryBrowse enabled="true" />
I am running IIS 7 on Windows 2008. The IIS server is pointing to the 2.0 version of the .NET framework. This should make no difference, but the server and workstation are all Japanese versions.
In VS2008, my Build Action setting for Service1.asmx.cs is Compile.
If I simply take the code in the .cs file and include it all in the ASMX (throwing away Code Behind logic entries) all is good. However, I need the code behind in my real application so I don't want to use this kind of work around. It seems to boil down
to Code Behind not be read properly...
I have scoured everything on the Internet for days, and can't solve my problem...... But now I have same problem recreated exactly using the simple recreation method in the above post. Any ideas on what this could be?
<%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="WebService2.Service1" %>
/// Service1 の概要の説明です
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// この Web サービスを、スクリプトから ASP.NET AJAX を使用して呼び出せるようにするには、次の行のコメントを解除します。
public class Service1 : System.Web.Services.WebService
public string HelloWorld()
return "Hello World";
Apr 02, 2010 06:22 AM|thomad|LINK
Not sure what's wrong but I'd try the following:
You might be interested in the article that explains asp.net compilation:
Hope this helps.
Apr 05, 2010 01:01 AM|jpnuser|LINK
It was great information. I read the whole article and found it very informational. I tried out the App_Code directory with many different settings for having the "Code Behind" point to the App_Code directory, but to no avail. I also successfully compiled
the "dumbtest"code with the aspnet_compiler.exe with no errors, with no end result change.
In the meantime, I'm throwing all my code into the asmx file, thereby removing the need for Code Behind altogether. It's getting me by for now, but probably won't hold up for very long.
If you have any other good ideas or information to pass along, please do so!
May 18, 2012 12:23 PM|rishi76|LINK