Skip Ribbon Commands
Skip to main content

Quick Launch

 

 Important Posts

 
 Complete MOSS Licensing Info
 SharePoint Speak Terminology Dictionary
 SPCAP - SharePoint Capacity Planning Tool
 Step-by-Step – A REAL world upgrade of a SharePoint Portal Server 2003 (SPS) farm to Microsoft Office SharePoint Server 2007 (MOSS)
 Best Practice - Determine if a SPUser has Admin rights to the SPWeb
 SharePoint 2010 - Good, Better, Best
Cornelius J. van Dyk's SharePoint Brain Dump > Posts > How do I – Solve the “Could not create type WebService.Name” error when trying to deploying a web service?
October 10
How do I – Solve the “Could not create type WebService.Name” error when trying to deploying a web service?

OK, so you wrote a web service and you may even have tested it and everything worked fine. So the you did some "cleanup" and tried to deploy the web service. It compiles and deploys just fine, but when you try to invoke and hit the service you are presented with the following error:

Server Error in '/' Application.

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 'WebServices.Candidates'.

Source Error:

 

Line 1: <%@ WebService Language="C#" CodeBehind="Candidates.asmx.cs" Class="WebServices.Candidates" %>


Source File: /Candidates.asmx    Line: 1

 

So just how do you solve this problem?

Here's my checklist of things to check when having trouble deploying web services:

  1. Check that IIS is using ASP.NET 2.0.
    1. Begin by starting up the Internet Information Services manager.
    2. Expand "Web Sites".
    3. Expand your web site e.g. "Default Web Site".
    4. Locate the Virtual Directory to which the web service was deployed and right click it.

    1. On the popup menu, click "Properties".
    2. On the Properties window, select the "ASP.NET" tab.
    3. Ensure that the APS.NET Version is set to 2.0.x and not 1.1.x.
    4. If it is set to 1.1.x, set it to 2.0.x and retry your web service.
  2. Ensure your Visual Studio build properties are set correctly.
    1. Locate the .asmx file in your Solution Explorer pane and right click it.

    1. On the popup menu, click "Properties".
    2. Ensure that the Build Action is set to "Content".

    1. Locate the code behind (.cs or .vb) file in the Solution Explorer and right click it.

    1. On the popup menu, click "Properties".
    2. Ensure the Build Action is set to "Compile".

    1. If either of these weren't set correctly, make the correction, recompile, redeploy and retest.
  3. Ensure ASP.NET 2.0 is an Allowed web services extension.
    1. Open the IIS Manager.
    2. Expand your computer.
    3. Click the "Web Service Extensions" option.
    4. In the right hand pane, locate the "ASP.NET v2.0.x" entry and ensure that its Status is "Allowed". If it is not allowed, the "Allow" button on the left will be enabled. Click it to change the setting.

    5. If it was not allowed, correct the setting and retry your service.
  4. Check for the WebMethod attribute.
    1. Review your code and ensure that you have the [WebMethod] attribute set for all web methods in the service. This does not mean that all methods have to be web methods, but the ones you are trying to consume should have this attribute in its declaration.

  5. Ensure the .asmx and code behind file match definitions.
    1. Open your code behind (.cs or .vb) file.
    2. Look at the web service declaration at the top.

    1. In our example, ensure that #2 and #3 match. If they don't, correct the problem.
    2. Next note the namespace at #1.
    3. Now open the .asmx file. This can usually be done by double clicking it in the Solution Explorer, but if you're not able to get it to open through the IDE, open Windows Explorer, navigate to the file, right click it and select Open in Visual Studio to work around the problem.
    4. Now look at the code.

    1. Note the value of Class in this case is "WebServices.Candidates". The Class value should be the full namespace value as well as the class name. Given our code behind file's values, in this case, the Class value should have been "Crowe.PartnerNomination.WebServices.Candidates", but instead it is just "WebServices.Candidates". This is a common issue when reworking already written web services into a namespace hierarchy. For some reason the .asmx file does not always reflect the changes made which then causes the error message at the beginning of this post.
    2. Change the Class value, recompile, redeploy and retest.

Later
C

Fave it Digg it Reddit Del.icio.us

Comments

mohan_8300@yahoo.co.ANTISPAM.in

I did the same way..but stil getting the same error ..
Could not create type 'WebService.XRules'. XRules.asmx

Can you please tell me where i am going wrong

My asmx page is
<%@ WebService Language="C#" CodeBehind="~/App_Code/XRules.cs" Class="WebService.XRules" %> 1

and my WebService page is

namespace XRules
{
/// <summary>
/// Summary description for XRules.
/// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class XRules : System.Web.Services.WebService
{
public XRules()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..
 on 10/29/2007 11:47 AM

http://www.cjvandyk.com/blog

Hey Mohan,

I'm not entirely sure why its not working for you.
I would start by commenting out everything except the shell of the web service.
Compile that and make sure it works.
Then add code back block by block until it breaks to narrow down the problem area.

Later
C
Cornelius J. van DykNo presence information on 11/1/2007 5:22 AM

http://discretelife.blogspot.com

Perfect! Setting 'content' on .asmx file and 'compile' on .asmx.cs file worked for me.
 on 1/16/2008 9:40 AM

http://www.cjvandyk.com/blog

Hey discretelife,

Glad to help out.

Later
C
Cornelius J. van DykNo presence information on 1/17/2008 5:17 AM

abc

hi mohan,

your namespace is wrong :) it is like:

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

but it should be like:

<%@ WebService Language="C#" CodeBehind="~/App_Code/XRules.cs" Class="XRules.XRules" %>
 on 2/20/2008 12:49 AM

http://www.cjvandyk.com/blog

Hey abc,

Good eye!

Later
C
Cornelius J. van DykNo presence information on 2/20/2008 1:44 PM

bcsmith@roseint.ANTISPAM.com

I have a solution with two webservices, one works, the other one gets this "could not create type" error.  I inherited this guy so not sure how the projects were originally built, but neither of them will show the .vb codebehind separately in the solution explorer, so I can't see if it's marked for compile or not.  The server defaults to dotnet2 and both web services are set that way.  My IIS (5.1) does not show a web extensions tab like you display, but since one of these does work, I would assume that part's ok.


The code from the one that works looks like this:
<%@ WebService Language="VB" CodeBehind="TOCWebService.asmx.vb" Class="TOCWebService.TOCWebService" %>

and

<WebService(Namespace:="TOCWebService")> Public Class AuthenticationHeader : Inherits SoapHeader
    Public TypeString As String
End Class
Public Class TOCWebService : Inherits System.Web.Services.WebService

This guy successfully installs and using IIS to browse TOCWEBService brings up the methods expected and they work.

The code from the one that doesn't work is exactly the same, in every detail except the name TOCWebService is replaced by TOCExtWebSvc. 

 on 6/26/2008 7:37 AM

fahim.bhatty@us.bosch.ANTISPAM.com

thats weird. my app was set to asp1.1 instead of 2. the first thing on your list. thanks for saving me a lot of time!
 on 7/2/2008 9:03 AM

http://www.cjvandyk.com/blog

Hey bcsmith,

I think the first step is to get your .vb code behind pages to show up.  Have you tried browsing to the file system and seeing if the pages are there and opening them that way?

Thanks
C
Cornelius J. van DykNo presence information on 7/6/2008 1:19 AM

http://www.cjvandyk.com/blog

Hey Fahim,

I'm glad to hear my post was useful to you!  ;-)

Later
C
Cornelius J. van DykNo presence information on 7/6/2008 1:28 AM
1 - 10Next

PLEASE NOTE
Comments are moderated so posting your comment here, will NOT make it visible right away.  Once I've reviewed your comment, I will publish it for all to see.  This is unfortunately needed in order to deal with all the crapware and spambots that post to my blog on a regular basis.

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Your Email or Blog URL *


Body *


Attachments