托管服务器上的WCF异常

时间:2010-03-07 18:31:21

标签: wcf

我在网上搜索了一个解决方案,但还没有找到一个有效的解决方案。

我有一个使用WCF Web服务的Silverlight应用程序。

在我的开发环境中,一切运行良好。

当我发布到我的DiscountASP.NET帐户时 - 网络服务给了我以下例外:

“/ eLearning / Services”应用程序中的服务器错误。 无法找到作为ServiceHost指令中的Service属性值提供的类型'eLearning.Web.Services.Learning,eLearning.Web'。 “

请参阅以下实际例外情况:

http://www.christophernotley.com/eLearning/Services/Learning.svc

我已将“eLearning”作为Web应用程序 - 并将web.config移至根目录。

我还确认在Web服务的标记中,服务属性声明为“eLearning.Web.Services.Learning,eLearning.Web”。

关于我做错了什么的想法?

感谢。

克里斯

以下是Web服务的标记:

<%@ ServiceHost Language="C#" Debug="true" Factory="System.Data.Services.DataServiceHostFactory, System.Data.Services, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Service="eLearning.Web.Services.Learning, eLearning.Web" CodeBehind="Learning.svc.cs" %>

这是System.ServiceModel web config:

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="RestBehaviorConfig">
                <webHttp/>
            </behavior>
            <behavior name="webBehavior">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="DebugEnabled">
      <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <customBinding>
            <binding name="customBinding0">
                <binaryMessageEncoding/>
                <httpTransport/>
            </binding>
        </customBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        <baseAddressPrefixFilters>
    <add prefix="http://www.christophernotley.com/"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <services>
  <service behaviorConfiguration="DebugEnabled" name="eLearning.Web.Services.Learning">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
    </services>

</system.serviceModel>

1 个答案:

答案 0 :(得分:2)

嗯,在WCF场景中,您的服务URL由三件事决定:

  • 服务器名称
  • svc-file所在的虚拟目录(以及所有子目录)
  • svc文件本身的名称和扩展名

在您的情况下,网址为

http://www.christophernotley.com/eLearning/Services/Learning.svc

所以这引出了一个问题:

  • /eLearning真正定义为虚拟目录吗?
  • 虚拟目录下面是否有一个/Services子目录?
  • 是* .svc文件的名称是否正确?
  • 实际的服务代码在哪里?您是否有一个包含服务实现的程序集,它是否位于* .svc文件可访问的位置? (它的目录,一个。\ bin子目录)?或者是App_Code目录中的代码?这个目录在哪里??

更新:

我对你的设置感到有点困惑.....你说/eLearning/Services是一个应用程序 - 在IIS中定义的虚拟应用程序,对吗?

Learning.svc文件中,您定义了Learning.svc.cs的代码隐藏文件 - 那么您的服务代码是否存在? (因为在另一个声明中,你提到了/ eLearning下的。\ bin目录 - 你的服务被编译成一个部署到那个bin目录的程序集吗?)