嗨,大家好,真的很感謝修復它,這讓我很生氣。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的快遞不支持無文件激活「。
任何人都可以提供更好的答案嗎?
乾杯, 澳瑪
這應該是在裏克斯答案的評論,如果他的回答是正確的,也請標記爲正確。 – ZoomVirus 2014-09-22 11:00:28