【问题标题】:WCF Service, the type provided as the service attribute values...could not be foundWCF 服务,作为服务属性值提供的类型...找不到
【发布时间】:2012-09-28 19:02:08
【问题描述】:

我很久以前就遇到过这个问题,只是想不起如何解决它或提出新的问题。我创建了一个 WCF 服务,稍后我将在 Web 应用程序中使用它,该服务从远程位置调用 WCF 服务等。现在我正在尝试在 IIS 中托管,甚至尝试了 WCFTestClient。我尝试浏览服务时遇到的错误;如下:

The type MyService.Service1 provided as the Service attribute 
value in the ServiceHost    directive, or provided in the 
configuration element system.serviceModel/serviceHostingEnvironment/
serviceActivations could not be found.

我认为它可能是我的 web.config 文件,但我看不出有什么问题:

<?xml version="1.0"?>
<configuration>

<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
  <webHttpBinding>
    <binding name="webHttpBinding" crossDomainScriptAccessEnabled="false" />
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="webHttpBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="webHttpBehavior" name="WcfInstanceRules2.Service1">
    <endpoint address="" 
     binding="webHttpBinding" 
       contract="WcfRules2.IServiceS"     behaviorConfiguration="web"/>
    <endpoint address="mex" 
    binding="webHttpBinding" contract="IMetadataExchange"></endpoint>
  </service>
</services>

我希望这最终成为一个以 json 格式提供数据的休息服务。

【问题讨论】:

    标签: visual-studio-2010 wcf


    【解决方案1】:

    检查您的 .svc 文件并查看它所引用的服务 - 可能是 MyService.Service1,它在您的配置中不存在。看起来它应该引用 WcfInstanceRules2.Service1。

    【讨论】:

    • 你认为我应该创建一个虚拟目录
    • 您不是在 IIS 中托管吗?如果是,那么如果您还没有这样做,请创建一个。
    • 我使用 Visual Studio 将它发布到 IIS,它在 inetpub/wwwroot/GnipServices/WcfInstanceRules2/Service1 中创建了一个文件夹
    • 你能浏览它或创建一个ServiceReference吗?如果您使用的是 WCF 4.0 或 4.5,则可以消除 .svc 文件...看这里msdn.microsoft.com/en-us/library/ee358764(v=vs.100).aspx
    猜你喜欢
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-12
    相关资源
    最近更新 更多