共用方式為


WCF Service Hosting Common Issues

Page Not Found (404) Error for WCF Service Hosted in IIS

On Windows 2003 Server, after installing IIS and WinFX, you may get this error when you navigate a .svc file from the browser. This is normally because the ASP.NET ISAPI filter is not enabled by default. There are two ways to enable it:

Approach 1: Rerun the command “aspnet_regiis.exe -i –enable” from a command window. This will reinstall ASP.NET and enable the ISAPI filter.

Approach 2: Using IIS UI Console,

(1) Open IIS Manager.

(2) Expand your machine node.

(3) Click on "Web Service Extensions".

(4) Find "ASP.NET v2.0.xxxxx". The current state would be "Prohibited". Click on "Allow" will resolve the issue.

Parser Error: Service Type Could Not Be Loaded During Compilation

You may get the following error message when you navigate a WCF service (.svc file) from a browser:

The CLR Type 'XXXX' could not be loaded during service compilation. Verify that this type is either defined in a source file located in the application's \App_Code directory, contained in a compiled assembly located in the application's \bin directory, or present in an assembly installed in the Global Assembly Cache. Note that the type name is case-sensitive and that the directories such as \App_Code and \bin must be located in the application's root directory and cannot be nested in subdirectories.

The error message is pretty explainable by itself. However, I still want to point out different situations when this can happen. Here is the format of the Service Directive of a .svc file:

<%@Service language=c# Class="<Managed Type>" [Other attributes] %>

Here are possible reasons why this can happen:

  • The specified string for the “Class” attribute does not represent an existing CLR type. Sometimes, this may be due to a typo. This string is case-sensitive. Also if you copy this from MS-Word, the quotes may be some special Unicode characters instead of the real ASCII quotes.

  • If you have the assembly (containing the service type) in the \bin directory, it is possible that you did not create a virtual directory so that its root directory contains \bin as its immediate sub-directory.

  • If you have your type in a code file under \App_Code, it may be due to the same reason as above.

Comments

  • Anonymous
    May 29, 2009
    The comment has been removed

  • Anonymous
    February 27, 2012
    Will it refer to the DLL contains the Factory class resides in GAC but not in the Bin folder? We are facing such issue where DLL resides in the GAC but still we had to put it into Bin folder.

  • Anonymous
    January 19, 2015
    This article is really helpful.