【发布时间】:2012-05-26 23:38:02
【问题描述】:
我在此链接中创建了 Web 服务库 http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec
为了发布它,我点击了链接http://naztek.wordpress.com/2009/08/27/host-a-wcf-library-in-iis/
但我在运行时收到此错误
“/WCFService1”应用程序中的服务器错误。
“服务”类型,在 ServiceHost 指令中作为服务属性值提供,或在配置元素中提供 system.serviceModel/serviceHostingEnvironment/serviceActivations 可以 找不到。
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。
异常详细信息:System.InvalidOperationException:“服务”类型,在 ServiceHost 指令中作为服务属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。
我的web.config 是:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="test1.Try">
<endpoint address="http://localhost:8732/Try" binding="webHttpBinding" contract="test1.Try"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
来源错误:
在执行当前 Web 请求期间生成了未处理的异常。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
[InvalidOperationException:“服务”类型,作为 ServiceHost 指令中的服务属性值提供,或在 配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 可以 找不到。]
【问题讨论】: