"Could not create type..." error deploying webservice

I know this question has been asked a billion times already because I've found several instances on the net, but none of the proposed solutions seems to solve my problem, so I'd appreciate any help.

I've created a C# webservice on my local machine that runs fine. Now I'm trying to deploy it to a webserver. The server is Windows 2003 with IIS 6. I created a new virtual directory in IIS, set it to be an application, and gave it "scripts only" execute permissions. I've manually copied all the files from my local webservice directoy to the virtual directory on the server. When I try to access the page, I get the dreaded "Could not create type 'Service'" message. Here is some additional interesting information:

1. I'm new to VS 2005 / .NET 2.0, and still kind of new to webservices in general. I've noticed that when I build the webservice on my local machine, it doesn't create a .dll for my service like webservices I created with VS 2003. Instead the App_Code directory sits in the virtual directory containing my code file, and apparently the website is dynamically compiling it. There is no 'Bin' directory (well, technically there is because I added a reference to a class library, and it's dll sits there, but there's nothing compiled from my project there). Is this copacetic? I read up on the "publish web site" feature that is supposed to generate an already-compiled dll, but when I tried it it didn't work either.

2. My local machine is running IIS 5. On the settings for the local virtual directory, I've noticed that the web service is set to use integrated windows authentication (might have set that myself manually, don't remember). By default it's not on the production web server, but turning that on does not make it work.

3. On the ASP.NET tab of the virtual directory properties, by default the asp version was set to 1.1 (under which I get the "Could not create type" error). When I try changing it to 2.0 (which I figure is what I need, given that I developed the service under 2.0), I get a "Page cannot be displayed" error instead.

4. I tried at one point creating a web deployment project, which created an msi file I ran on the webserver. All that seemed to do was do exactly what I did manually, still resulting in a non-working web service.

Why is setting up a virtually trivial web service so stinking hard?

[2454 byte] By [awesj] at [2007-12-23]
# 1

Hello,

Could you please post the entire error message? Was there any indication as to why the Service instance could not be created?

Daniel Roth

DanielRoth at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2

I am getting the same error.

I have Visual Studio 2005 Team Edition for Software Developers.

I am doing the following steps

1. Create New Web Service

2. Right Click on Project and Publish at http://localhost/Website2

First it gives the following error

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized configuration section 'connectionStrings'

Source Error:

Line 10: <configuration>

Line 11: <appSettings/>

Line 12: <connectionStrings/>

Line 13: <system.web>

Line 14: <!--


Source File: c:\inetpub\wwwroot\Website2\web.config Line: 12


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Now remove the

<appSettings/>

<connectionStrings/>

lines from the code

and Right Click and Publish again at the same location

Now if you access http://localhost/WebSite2/Service.asmx

You will find the following error

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not create type 'Service'.

Source Error:

Line 1: <%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %>


Source File: c:\inetpub\wwwroot\WebSite2\Service.asmx Line: 1


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Any Idea how to remove it?

Any other work around to distribute a website without code?

Armoghan at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3

Sorry guys, i Found the problem. I also had ASP.NET 1.1 installed on the system and IIS was pointing to it

Armoghan at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 4

Hello Friends,

The problem is because your application is using ASP.NET V1.1 for the execution of Webservice build in ASP.NET V2.0

Here is the solution.

just go to the properties of your virtual directory.

now go ot the ASP.NET Tab

here change ASP.NET Version from 1.1 to 2.0

Thank You,
Hardik Mehta.

HardikMehta at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 5

still not work after i follow that solution...

any idea?

akois at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 6

i got the solution..

make sure set your

1. webservice.asmx file properties > Build set to Contents

2. webservice.asmx.vb file properties > Build set to Compile

akois at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 7
ASP.NET 2.0 seems to assume that its App_Code directory is right underneath the vroot. Just make sure the reference to the vdir is pointed correctly.
Waheeda at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 8

I had the same problem and I was going nuts to find the solution.

Hardik's suggestion works. Thanks.

pragaw at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 9
akois wrote:

i got the solution..

make sure set your

1. webservice.asmx file properties > Build set to Contents

2. webservice.asmx.vb file properties > Build set to Compile

think running on the local server is a starter part of the problem.After thousands of forum and resource search i came over the deployement problem of web services.

This answer may not match the question but someone should concern about the problems while deploying web service to web.
First of all you have correct the problems depends on the configurations on web.config file.Remove the authantication setting and define custom error tag like below.Also before deploying, you may set compilation debug to "false".

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<
error statusCode="403" redirect="NoAccess.htm"/>
<
error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>

Be sure web service is running on local.After this upload the directory, enter the control panel of your hosting (plesk or cpanel) create virtual directory which shows the real one.

Open internet explorer and write the url of virtual directory.

The reason i wrote these is that i have searched a lot about this but the is no answer about this problem.At last i found it and wanted to share this information.I appologise If there is any grammer or spelling mistakes.

Thanks everybody... Kvtlv

Kvltv at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 10

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,.NET Development,ASMX Web Services and XML Serialization...
# 11
make sure you have the [WebMethod] addribute set on all your methods.
Kapil at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 12

A typical problem is that the class name doesn't match. For example, the class may be in a namespace and the .asmx file doesn't properly reference that namespace. Example:

<%@ WebService Language="C#" CodeBehind="~/App_Code/WebBackEndService.cs" Class="SnCore.BackEndServices.WebBackEndService" %>

code would be

namespace SnCore.WebServices
{
[WebService(Namespace = "http://www.vestris.com/sncore/ns/", Name = "WebContentService")]
[
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebContentService : WebService { ...

dB. at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 13

A typical problem is that the class name doesn't match. For example, the class may be in a namespace and the .asmx file doesn't properly reference that namespace. Example:

<%@ WebService Language="C#" CodeBehind="~/App_Code/WebBackEndService.cs" Class="SnCore.BackEndServices.WebBackEndService" %>

code would be

namespace SnCore.BackEndServices
{
[WebService(Namespace = "http://www.vestris.com/sncore/ns/", Name = "WebBackEndService")]
[
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebBackEndService : WebService { ...

dB. at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 14
I was accessing a subdirectory of the vroot, and changed the reference location in the asmx file but still didn't work. When I made the subdirectory to a virtual directory, it worked.
ismaelc at 2007-8-30 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified