问题
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.
回答1:
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.
回答2:
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" %>
回答3:
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!
回答4:
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!
回答5:
Remove sites/Tokhin/ part like this:
then it will work..
回答6:
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
来源:https://stackoverflow.com/questions/19908936/web-service-parser-error-message-could-not-create-type-xxx