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

    Question

  • 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?

    Wednesday, February 08, 2006 11:16 PM

Answers

  • 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.

     

     

     

    Tuesday, March 14, 2006 5:31 AM
  • Sorry guys, i Found the problem. I also had ASP.NET 1.1 installed on the system and IIS was pointing to it

     

    Wednesday, February 15, 2006 10:46 AM

All replies

  • 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

    Tuesday, February 14, 2006 1:28 AM
    Owner
  • 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?

    Tuesday, February 14, 2006 7:48 AM
  • Sorry guys, i Found the problem. I also had ASP.NET 1.1 installed on the system and IIS was pointing to it

     

    Wednesday, February 15, 2006 10:46 AM
  • 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.

     

     

     

    Tuesday, March 14, 2006 5:31 AM
  • still not work after i follow that solution...

    any idea?

    Monday, March 27, 2006 1:54 AM
  • 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

     

     

    Friday, March 31, 2006 4:22 AM
  • 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.
    Friday, March 31, 2006 4:34 PM
  • I had the same problem and I was going nuts to find the solution.

    Hardik's  suggestion works. Thanks.

    Wednesday, April 05, 2006 1:10 PM
  •  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

    Wednesday, April 19, 2006 3:00 PM
  •  

    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!

    Saturday, May 20, 2006 3:45 AM
  • make sure you have the [WebMethod] addribute set on all your methods.
    Wednesday, June 21, 2006 6:06 PM
  • 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 { ...

    Wednesday, July 19, 2006 1:07 PM
  • 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 { ...

    • Proposed as answer by guru4utoo Monday, December 29, 2008 6:23 PM
    Wednesday, July 19, 2006 1:08 PM
  • 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.
    Tuesday, July 25, 2006 9:12 AM
  • Thank You. I spend 2 days trying to fix it. The problem was that i missed namespase in "Class=....".

     

    Thursday, August 03, 2006 2:38 PM
  • This really helped me - thank you :)  (I knew it's gonna be sth with the wrong path and that I need to tell VS where to find codeBehind class, but I didn't know how to do it)
    Monday, August 07, 2006 11:41 PM
  • Thanks dB - my problem was caused by an incorrectly referenced namespace;

    e.g.

    in Service.vb - "Public Class mywebservice ..."

    but in Service.asmx - "..Class="webservice".. ", which should have been "..Class="mywebservice".."

    cheers
    Monday, August 28, 2006 8:41 AM
  • my advice for web problems is this ,do not use the localhost.

    you have to use another or create another site and register it to a dns server .

    Tuesday, September 05, 2006 9:49 AM
  • I have see many explanations, may be could work for some, but no for me, after a hole afternoon I discovered a solution to my problem, I think this could help a lot of people who posted here for an answer (if you have IIS 6.0 and nothing that had been posted works for you):

    1. paste your solution as you do in IIS 5.0

    2. aggregate on the IIS 6.0 in the web site like a virtual directory

    3. Turn on your ServerExtension ASP:NET 2.0 or 1.4 whatever it is (dont put in the same appPool 1.x and 2.0 separate them)

    4. open the properties of the virtual directory down in the virtual directory tab is the application configuration click on create and set the execution permissions to execute scripts (my windows is an spanish version)

    done!

    you'll see that the icon has change

    Wednesday, October 11, 2006 10:40 PM
  • Check your compilation settings too.

    You can get this error if your target output directory is anything but bin\

     

     

    Thursday, October 12, 2006 3:49 AM
  • Yes Hardik,
    This is working perfectly.
    Thanks.
    Saturday, October 28, 2006 2:25 PM
  • After letting the MSI set up the virtual directory and contents I went into IIS and put the dll in the bin directory and that fixed it for me.
    Tuesday, October 31, 2006 4:54 PM
  • Yippee, just moving the dlls into bin from the root of the virtual dir (after using the setup wizard to install) worked for me.

    Cant be right though!  is it a bug in the setup wizard or am i missing a "compile to" setting?

    Friday, November 03, 2006 1:02 AM
  • Yeah, it doesn't seem quite right, but that's what fixed this problem for me, too.  The setup wizard ought to know better, but you can always fix the setup project by hand -- go to the File System view, and drag the "primary output" and dependent dll's to the bin folder, leaving the "content files" where they were.
    Friday, November 10, 2006 9:16 PM
  • Thanks DB.

    I have spend around two days to do all the stuff. I went throught all the iis settings but the name space specifiaction was missing in the Class. Really you blog helped me a lot.

     

    Any one who are new on webservce keep the follwing points and do make these changes before deploying the webservice.

    *) Check you IIS Settings according to the version you use. (Asp.NET TAB and Web Extensions Methods)

    *) check your project settings

    *) The web serviice .asmx file and .asmx.cs file need to be checked properly in the vdir and if the name space is included in the .asmx file specify it in the Class so that it works.

    I appolize if any spelling mistake are there.

     

    Vipin

    Tuesday, March 20, 2007 1:59 PM
  • I had the same problem. Hardik's solution worked.

    Thank you Hardik.

    Thursday, March 22, 2007 8:48 AM
  • I just found the older version 1.1.4322 but no new one even Framework 2.0 and 3.0 are installed on the server.

     

    I have tried every thing posted on this thread but the same message exists and the web service doesn't work.

     

    Any help please.

    Sunday, April 22, 2007 12:22 PM
  •  

    Hi guys.

    Still didn't get this to work...

    Can anyone please post a truely working published web service so that I can see the structure of the folders and the content of the asmx file and learn from that what changes needs to be made to my web service?

     

    Thanks!!

    Tuesday, May 08, 2007 10:02 PM
  • I had the same problem and problem was that makrup and real Service name were different.

    Probably the following will help:

    Right-click on asmx file -> View Markup.

    Change Class to the real class name (if you have you service named not "Service1" - check in code for in asmx.cs file)

     

    Best Regards, zeva

     

    Wednesday, May 16, 2007 7:24 AM
  • I got the same issue, but still can not make it works.

     

    Here is my settings:

    on OrderServ.asmx.vb:

    Public Class OrderServ

    Inherits System.Web.Services.WebService

     

    On orderServ.asmx:

    <%@ WebService Language="VB" CodeBehind="OrderServ.asmx.vb" Class="WebService.OrderServ" %>

     

    I developed the webservice and web application on the same machine under vb 2005 and IIS5.1. It works fine on my machine. After I create a setup project  and install webservice on a web server, win 2003 server and IIS 6.0, I can brows to the web service, but when I invoke any of web method, It give me this error.

     

    The website cannot display the page

     HTTP 500
     

    Most likely causes:

    • The website is under maintenance.
    • The website has a programming error.
     

    What you can try:

     

    Refresh the page.

     

    Go back to the previous page.

     

    More information

    On iis, I have set the virtual dir property to asp.net 2.0

     

    Any one can help/

     

    Thanks

    ylit

    Tuesday, June 19, 2007 7:47 PM
  • Can you please give me more details.

     

    What do you mean real class name? I have following files,

     

    on OrderServ.asmx.vb:

    Public Class OrderServ

    Inherits System.Web.Services.WebService

     

    On orderServ.asmx:

    <%@ WebService Language="VB" CodeBehind="OrderServ.asmx.vb" Class="WebService.OrderServ" %>

     

    Which one should be the class name?

     

    Thank you

    ylit

    Tuesday, June 19, 2007 10:17 PM
  • Hi awesj,

     

    Did you get rid of this cryptic error message "The page cannot be displayed" when trying to invoke the Web Method.

    I did see 1.1 which I changed to 2.0 and now the "Could not create type" error has gone but this new error while invoking the web method is making me go nuts.

     

    A quick reply would be highly appreciated.

    Thanks in advance.

    zullu.

    Friday, June 22, 2007 7:32 PM
  •  

    Hey, i found this solution! for the parser error problem!

     

    After trying different solutions, i found my own solution.

     

    Goto the properties of the virtual directory,

     

    Goto the ASP.NET tab,

     

    Choose version 2 of it,

     

    Click "Edit Configuration"

     

    Goto "Authentication" tab,

     

    change the authentication mode to "None".

     

    Thanks,

    Chandi prasad.B.

    Friday, June 29, 2007 4:20 AM
  • @Zullu

     

    Hey, did you check the URL that it is trying to access, if your answer is yes,

     

    Then check that you have all neccessary permissions granted to the IIS user account ( there is a special account created for iis normally) on the folder where your web application resides.

    Friday, June 29, 2007 5:53 AM
  • works perfect, thx a lot!
    Friday, June 29, 2007 3:33 PM
  • Please ignore this postif you already solve your problems.
    If the error is web.config file or about web confeguration error meaning your web server or web site is not ranning correctly review your iis documintation, see IIS help for more information .if you want instant sulotion about your problem just send e-mail to jasonperez_1@msn.com or administrator@mysmart.com.ph
    If you will just spend time reading the documintation you will not have any problem,everything is fully tested fully documented.
    Note: Dont forget to Regester your site (DNS)
    Be sure that your sebsite where you want to deploy is raning correctly,be sure that your website or domain is regesterd.Do not use the address localhost if passeble
    Saturday, June 30, 2007 10:27 AM
  • A link to a very simple walktrough creating webservice, http://www.msnusers.com/MicrosoftPhilippines/Documents/migrsoapwebserv%2Ehtm

    note you can only access this page if you have a passport or join Microsoft Philippines group.

    Saturday, July 14, 2007 6:00 AM
  • Dear dB - You are awsome. I could fix the simple problem in less than 3 hours with your help, not 2 days. Thanks a lot!!!
    Monday, July 23, 2007 9:22 PM
  • 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

     

     

    I had the same above problem but the solution was different. May be for different mistakes you make, you may get the same error. Here is my solution.

     

    The name was too long. I simply shortened it, it worked.

    In my case both namespace as well as the class name, both were long. So I shortened both of them.

    Now it is working fine. I havent done any more research on it like whats max number ofchars it accepts...

    Happy coding...

     

    Tuesday, October 09, 2007 8:41 PM
  •  

    The namespace mismatch solved my problem here.  Thank you!

     

    Colby Africa

    Thursday, October 11, 2007 5:12 PM
  • Microsoft probably looks upon this as a user error.  It is not.  This situation is simply another example of poor, in this case incredibly poor, software design.  The basic idea is to create solutions that might on occasion require "sold services" from Microsoft personnel.  Microsoft has zero incentive to make things straightforward or clear.

    I am currently in a forced situation and must figure out how to implement "all those files" needed to simply implement a simple 15 line program if I had not been forced to use Microsoft aspx or asmx files.

    My suggestion is simple.  Dump Microsoft on the server side of all anyones applications.  The savings will be tremendous.

    Meanwhile, I'm back to trying to fathom why I need all these files and why things work on the PC but refuse to work on the server.  I'm on my third day.  (Within a half-hour on the first day I had already done my demo in PHP.)

    If there is anyone at Microsoft that can provide a clean example it would certainly be appreciated.  Even clear error messages would work wonders but,
    -------------------------------------------------------------------------

    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 'MyService.WebService1'.

    Source Error:

    Line 1:  <%@ WebService Language="c#" Codebehind="WebService1.cs" Class="MyService.WebService1" %>

    -------------------------------------
    does not mean ***!  In fact it is less than helpful.  Microsoft software performed work.  It accessed or encountered a file or files in some way and something failed.  The least Microsoft should do is report the point of failure.  But, instead it refers to "parsing of a resource".  What resource????  Could it not find something?  Was what it found invalid?  Did it lie and not get to the point of parsing something at all?

    I'm pretty well fed up with the whole Microsoft world.  Just look at C#.  There must be 5 to 10 recommended ways just to say "Hello World".  That's insane!  Hello World is best said in any language but Microsoft.  Oh, and when is Microsoft going to create a "non-Visual Studio"?  I get so sick of reading, "first we need to . . . ".  I just want to know how to write "Hello World" in the language.  I edit c# code in Notepad anyway.  Well, at least Microsoft created one great product - Notepad.  And I've paid for it so many times buying all those versions of DOS and Windows for all my machines.  Unfortunately Linux desktop OS is still not there - YET.  But as soon as it is - not a penny more.  Not a penny more!
    Wednesday, October 17, 2007 6:11 PM

  • Bingo! this solution helped.
    Thursday, November 01, 2007 6:02 PM
  •  

    ylit> vb 2005 and IIS5.1

     

    Should this work on IIS 5.x?

    My Service works well in the ASP.NET Development Server window, but does not work on my IIS 5.x machine.

     

    Tom

    Thursday, December 27, 2007 8:00 PM
  • Plese create a separate thread, and post some details of the problems you're having.

     

    Thursday, December 27, 2007 11:02 PM
    Moderator
  •  

    By the way, if anyone wants to test some web services, use this link (live.com) to see what's out there (and working).

     

    Yes, I'll create a new thread to describe my specific problem.

    Friday, December 28, 2007 12:11 AM
  • Hi all, this problem is Coming Because asmx file is not able to locate the service.cs file which is in app_code folder so, if u want to get rid of this problem just give the correct path for this service.cs file and or u can copy ur entire code in server snd map virtual path for this, then u can access it. and will fine and for seting please refer very good blog by

    Cornelius J. van Dyk's SharePoint Brain Dump

    go to the link

    http://www.cjvandyk.com/blog/Lists/Posts/Post.aspx?ID=133
    Friday, January 25, 2008 8:40 AM
  • Hi,
    I am facing the same problem. I am working on VS 2005 with Vista and IIS7. Anyone can help me out.
    Kaushal
    Wednesday, August 06, 2008 10:02 AM
  • Please do not add on to another huge thread. Please start a new thread and please provide details of your problem. Some subtle difference between your problem and the one that started this thread several years ago may make the difference in helping you or not.

    John Saunders | Use File->New Project to create Web Service Projects
    Wednesday, August 06, 2008 1:14 PM
    Moderator
  • I had this issue today and remember having had it a year or so ago.

    I think it has already been said once or twice here but I'll repeat that the important thing to check is that the ASXM file references to the class is correct.  In todays' case, the App_Code was actually App_Data and I didn't realize it at first because the two look so similar that I just assumed it was correct.  Double check the path AND the namespace spelling.

    JHH

    Producer of The Tantalus Connection
    Friday, September 26, 2008 4:41 PM
  • This problem or similar once can occur if the Application Pool is not configured correctly.

    In my case I got the same problem, and checked that everything was setup correctly to use .NET 2.0 etc. Since that did not solve my problem I created a newly installed test server (Win 2003, IIS6) and published the same Web Service there... everything worked within 5 mins. *brain dump*

    So what was the difference between my live server and my test server I though. After going everything through again and finding nothing, I noticed that because of our way to structure departments in subdirectories my Web Service was placed deeper on the live server then on the test one.

     

    Solution: I made the whole department directory an Application pool, and also that single subdirectory where my newly created Web Service was placed.

     

    -          wwwroot

    o        department (App_pool)

    §          Subdirectory (App_pool)

    ·          Newly created Web Service

    §          Subdirectory

    Hope it helps someone, cause this error apparently can be cause by alot of diffrent things.

    Cheers, John B

    Sunday, October 19, 2008 10:02 PM
  • Easy Fix: 

    Struggled with this for a while so I am happy to save someone else some time.  Its IIS not your code.

    • Launch IIS
    • Goto the Directory or Website.
    • Right-Click -> Properties.
    • Look at the 'Application Name' field: Is it greyed out?
    • If so press 'Create' button
    • Now it should be working.

    • Proposed as answer by JulsAgain Monday, October 27, 2008 3:04 PM
    Monday, October 27, 2008 3:04 PM
  • Thank you sooooo much. My issue was resolved by using both the Name:= and the Class (i.e. service.MyWebService). It was not intuitive but made sense from your code sample.
    Monday, December 29, 2008 6:22 PM
  • genius, that worked a treat!
    Tuesday, June 30, 2009 8:11 AM
  • I'm locking this thread because it's ancient. Most recent replies have been "thanks, it worked", which is a pleasant sentiment, but doesn't help out those who come after us.

    Please, if you have what you believe is s similar issue, then please read this thread, and if it doesn't help, then please create your own thread.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of old ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Wednesday, July 01, 2009 1:06 AM
    Moderator