2013-03-17 53 views
1

嗨,大家好,真的很感謝修復它,這讓我很生氣。WCF4服務主機無文件激活配置錯誤

使用VS2010 SP1 + .Net 4.0 + IIS 7.5 Express。

一個旨在託管WCF服務的簡單Web項目會引發配置異常,原因不明。主機是一個使用無文件激活的空Web應用程序。

基本上如下:

namespace MyWCFServices 
{ 
public class HelloWorldService: IHelloWorldService 
    { 

     public string GetMessage(string name) 
     { 
      return string.Format("Hello world from {0}!", name); 
     } 
    } 

[ServiceContract] 
    public interface IHelloWorldService 
    { 
     [OperationContract] 
     string GetMessage(string name); 
    } 
} 

的Web.config

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
      <system.serviceModel> 
     <serviceHostingEnvironment > 
     <serviceActivations> 
      <add relativeAddress="HelloWorldService.svc" 
       service="MyWCFServices.HelloWorldService"/>        
     </serviceActivations>      
     </serviceHostingEnvironment>      
     <behaviors> 
     <serviceBehaviors> 
      <behavior> 
      <serviceMetadata httpGetEnabled="true"/>          
      </behavior>        
     </serviceBehaviors>      
     </behaviors>    
    </system.serviceModel> 
</configuration> 

例外:在 '/' 應用

服務器錯誤。

配置錯誤

說明:該請求提供服務所需的配置文件的處理過程中發生了錯誤。請查看下面的具體錯誤細節並適當修改您的配置文件。

解析器錯誤消息:無法識別的元素。

源錯誤:

Line 3:  <system.web> 
Line 4:   <compilation debug="true" targetFramework="4.0" /> 
Line 5:  </system.web> 
Line 6:  <system.serviceModel> 
Line 7:  <serviceHostingEnvironment > 

---編輯:

在IIS論壇上同樣的問題:http://forums.iis.net/t/1180211.aspx/1

答案是非常不好的,「也許是IIS的快遞不支持無文件激活「。

任何人都可以提供更好的答案嗎?

乾杯, 澳瑪

回答

1

奇怪。我的權利複製你的XML並粘貼到我的項目,它工作得很好。也許你的文件中有一個隱藏的字符?嘗試剪切並粘貼到記事本中,然後將其從記事本中複製回新的web.config文件中。

0

瑞克看起來像你的懷疑是正確的。

我從零開始重新輸入配置文件並解決了問題。

在這種情況下,IIS應該產生一個描述性的錯誤,誤導只是看到'無法識別的元素'。

+0

這應該是在裏克斯答案的評論,如果他的回答是正確的,也請標記爲正確。 – ZoomVirus 2014-09-22 11:00:28

0

我有此錯誤消息:

Description: An error occurred during the processing of a configuration file required to service this request.

Parser Error Message: Unrecognized element.

對我來說是我的網站設置爲IIS應用程序和應用程序池設置爲集成託管管道模式下的4.0架構的解決方案。