2005 - "could not create type 'service'"

Building a web service project with Beta 2... this project built OK under CTP 12/04. Building now I keep getting this error: ""could not create type 'service'". There is no further info provided about the cause of this or what it means. Searching help does not bring up anything. Clicking on the error in the list brings you to the Service.asmx file, highlighting the only line, which reads:

<%@WebServiceLanguage="C#"CodeBehind="~/Application_Code/Service.cs"Class="Service" %>

I saw a thread in one of the newsgroups that suggested that this error would occur if you wrapped a namespace around the class, but this code is not doing that.

Any ideas or suggestions? As I mentioned, this project built under the CTP. It never WORKED, but we had high hopes that it would once we tried it under Beta 2, so the fact that we can't even BUILD it now is somewhat frustrating.

ddk

[1338 byte] By [MiloT.Minderbinder] at [2008-3-7]
# 1
I've just been suffering the same problem when I discovered your question on this forum. In case you're still looking for an answer, in my case I solved the problem by changing the 'Code' sub-directory to 'App_code' - and away she went!!

chargrill

char_grill at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 2
Yea, that was basically the upshot of how I solved it... although, instead of just changing the name of the folder, I created a new project, then imported in all the code etc.
MiloT.Minderbinder at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 3

This is what worked for me.

Open IIS Manager

In the left "tree view" find "Web Service Extensions" and highlight it.

Locate the "ASP.NET v2.0.50727" element, highlight it and click the Allow button. This will make Framework 2.0 your default ASP version.

Next, go to the properties dialog of your Web Service Site (still in IIS Manager) and select the ASP.NET tab. Set the Framework version to 2.0.50727.

I puzzled over this for at least a day. Now I'm as happy as a little girl!

KevinMcConathy at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 4

Hi Chaps,

Also a newbie to .NET 2.0 web services, so please forgive if totally obvious.

What solved my build error "could not create type 'service'" was changing the Class="Service" in the header of my asmx file to the same as the name of my public class which implements the web service in the .cs file.

i.e. if webservice1.cs contained public class mywebservice ...

in webservice1.asmx I changed Class="Service" to Class="mywebservice"

Thanks for the other tips as well!

Karl

KarlH at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 5
I posted this earlier. It fixed me.

Open IIS Manager

In the left "tree view" find "Web Service Extensions" and highlight it.

Locate the "ASP.NET v2.0.50727" element, highlight it and click the Allow button. This will make Framework 2.0 your default ASP version.

Next, go to the properties dialog of your Web Service Site (still in IIS Manager) and select the ASP.NET tab. Set the Framework version to 2.0.50727.

I puzzled over this for at least a day. Now I'm as happy as a little girl!

KevinMcConathy at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 6

I encountered the same problem....n the mistake that i have made was that i didn gave the fully qualified name of the class in my ASMX file.It is to be noted that the ASMX file needs the fully qualified name of the class, including any namespace.

(eg:

<%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="MTC.SSO.MTCSSO" %>

where MTC.SSO is my namespace and MTCSSO is my class name.

)

GinoMatthew at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 7
Thanks Kevin!! It solved my problem as well. Many thanks! <3
Yui_Ikari at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 8

Hi guys,

I am new to .NET and for some days I've been trying to create a "HelloWorld" web service, and deploy it properly so that it is accessed from an outside client. Creating the code of the service was a piece of cake actually and it works when I click on 'Preview in browser' in the VS's Solution Explorer but when I deploy it on local IIS I get the error that most of you refer to in this discussion. I browsed through your posts but none of the suggestions actually worked out for me. Here is my code:

using System;

using System.Data;

using System.Web;

using System.Collections;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.ComponentModel;

/// <summary>

/// Summary description for SayHelloWorld

/// </summary>

[WebService(Namespace = "http://myspace.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[ToolboxItem(false)]

public class SayHelloWorld : System.Web.Services.WebService

{

[WebMethod]

public string HelloWorld()

{

return "Hello World";

}

}

and my Service1.asmx file content:

<%@ WebService Language="C#" CodeBehind="~/App_Code/Service1.asmx.cs" Class="SayHelloWorld" %>

I followed an MSDN tutorial precisely ( http://msdn2.microsoft.com/en-us/library/87h5xz7x(VS.80).aspx ) for deploying the service and I ended up with an exe file that was supposed to deploy it authomatically to localhost. Only at the end the familiar to you error "Could not create type 'SayHelloWorld'." appears on the screen. I tried removing the namespace that was generated by default, but it didn't work. Could it be because I don't have the Front Page extensions installed or maybe some issue with the version of .NET (I use VisualStudio 2005 and .NET 2.0)? One more thing - there is nothing in the bin folder when I check the my application folder in IIS manager. Is it normal?

Any hints and conjectures are highly appreciated! Thank you in advance!

Mr.Guglev at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 9
Hello!Mr guglev
im not sure if this would help you at all,but i used to have the same problem.
1) see if ur IIS is 6.0
2) check if it supports ASP 2.0
3) "/App_Code/Service1.asmx.cs" -> i deleted the ~ and it seems to work. Also make sure the folder is actually there
4) i didnt use front page extension because it likes to make ur life a living hell. I upload it through ftp and that fixed the"front page extension errors"

These is what i read from different sites, it seems to work.
Also changing the name space that was generated by default shouldn't matter for ur error. Make sure u r uploading it right and if u have all the proper files in ur web service(as in,make sure u r not missing any) .Double check the paths and try again.

" One more thing - there is nothing in the bin folder when I check the my application folder in IIS manager. Is it normal?" ->nothing?@_@

Yui_Ikari at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 10

What worked for me was creating a virtual root in IIS Manager. I was just copying my website (folder containing Service.asmx and App_Code, App_Data) to the IIS created wwwroot. WHat one should do in addition is:

1. open IIS Manager (one way is Start-> Run -> inetmrg)

2. In the left tree, browse to <your computer name>->Web Sites -> Default web sites.

3. right click on default web sites, choose New->Virtual directory.

4. In the wizard that opens ,CHoose some name for your virtual directory, say XYZ, and next select the folder where your website is copied. Suppose your website main file is named Service.asmx

Now point your browser to http://localhost<or computer name>/XYZ/Service.asmx

This is the link your web service clients hsould also use.

Anonymous at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 11
The only thing I had to do was changing my asmx.cs file to the App_Code folder.
Anonymous at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 12
Thanks Gino, I added a namespace and had this problem. Adding the namespace to the class attribute solved it.
kmac at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 13
Great thanks. Worked for me too.
gilstav at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...
# 14

Karl,

you are a *#$%ing genius. I added a namespace to my generated class to make it consistent with the overall project. As you suggested I went back and modified the asmx file to point to the class prefixed with the namespace and everything worked fine.

commonsense - there are a multiple solutions to a single problem.

.net sense - There are multiple causes for a single error message

narsimanv at 2007-8-30 > top of Msdn Tech,Feedback for forums and MSDN websites,Off-Topic Posts (Do Not Post Here)...