Reputation: 3441
I am getting a parser error when i try to browse my web service.
Already found so many answers, but none helped me. If anybody can guide me to a helpful link that i might have overlooked, it will be of great help.
Here is the scenario :
I have web service built in VS-2010 (framework 4.0) hosted on IIS 7.5 which uses "ASP.NET v4.0 Classic" app pool. This used to work fine until i reinstalled it. It started showing the Error below
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 'AuthenticateUser'.
Source Error:
Line 1: <%@ WebService Language="C#" CodeBehind="~/App_Code/AuthenticateUser.cs" Class="AuthenticateUser" %>
Source File: /WebService101/Services/AuthenticateUser.asmx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016
Please Help.
Upvotes: 19
Views: 42915
Reputation: 99
I've run into this problem today after renaming the class name in the ASMX.CS file. I tried a number of different solutions to try to fix the problem, but none of them worked for me:
What DID work for me was creating a NEW ASMX file and copying the old code into the new ASMX.CS file.
To do this in Visual Studio, just go to the Solution Explorer
, right-click on the CS Proj
-> Add
-> Add New Item
and choose the Web Service (ASMX)
option. That will create the new ASMX file and then you can just copy your code into the new file and delete the old object.
Not sure how or why this fixed anything, because the new ASMX file seems identical, but it did fix the problem for me. Maybe there was a bad reference somewhere in the Visual Studio or CS Project settings?
Upvotes: 0
Reputation: 1
After 6 days, I found the mistake.
I had the same error as you:
Web service Parser Error Message: Could not create type 'xxx'
I found that when I upload the publish files on the host I put the projectnam.dll
in the main root(wwwroot) then I created the bin folder in the host then I put projectname.dll
(in the publish folder) and the problem is solved.
Upvotes: 0
Reputation: 1572
The problem is that ASP is looking for a class named AuthenticateUser but it cannot find it.
In Visual Studio, right click on the webservice file (AuthenticateUser.asmx) and select "View Markup". This will let you find Line 1 of the asmx file where the error is. Look at the end of this line. In your example,
Line 1: <%@ WebService Language="C#" CodeBehind="~/App_Code/AuthenticateUser.cs" Class="AuthenticateUser" %>
Check to see the Class matches the Public Class name you gave your webservice. In other words, did you rename the Class to "AuthenticateUser" or to something else after you created this file? Sometimes the class mentioned in Line 1 does not match the name you gave the class in the webservice asmx file.
To fix this problem, the line in the beginning of your webservice should match the class mentioned in Line 1 and look like:
Public Class AuthenticateUser
...your webservice code here...
End Class
Upvotes: 1
Reputation: 318
I had this problem and I was racking my head for days and doing a lot of research online. It was basically because the file and the class have to be the same name i.e. I had cut the code from somewhere else and the class was called fileUploader. The file was called fileuploader.ashx.
So, that is what was causing my problems. When I renamed the class to fileuploader, it worked perfectly. Ahhhh!! Several days wasted!
Upvotes: 1
Reputation: 191
Also, check to ensure that build output path is to the "bin\" folder ONLY. A Web Service project cannot use the DLL files generated if they are stuck under "bin\Debug\AnyCPU" or "bin\Release\x86".
A colleague and myself spent 2 hours trying to make a Web Service project work on a new workstation that had worked perfectly on an old machine.
Hope this tip helps someone else using Google!
Upvotes: 19
Reputation: 20091
I got the same error, in my case resolution was to use full qualified class name (class name with namespace) in the .asmx file.
<%@ WebService Language="C#" CodeBehind="~/App_Code/AuthenticateUser.cs" Class="AuthenticateUser" %>
would become
<%@ WebService Language="C#" CodeBehind="~/App_Code/AuthenticateUser.cs" Class="MyProjectName.AuthenticateUser" %>
Upvotes: 19
Reputation: 246
Please check whether all your dll's are present in the web service folder. i was able to find this with the help of a tool called "Beyond Compare". where i compared older working copy of Web service directory to the new one.
Upvotes: 13