2010-03-07 186 views
1

我在网上搜索了一个解决方案,但还没有找到一个可行的解决方案。托管服务器上的WCF异常

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

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

当我发表我的DiscountASP.NET帐户 - Web服务使我有以下异常:

“服务器错误/电子教学/服务“应用 类型“eLearning.Web.Services.Learning。 ,eLearning.Web”,在ServiceHost的指令中的服务属性值提供找不到“

请参照实际的异常在:

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配置:

<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> 

回答

2

那么,在一个WCF方案,为您服务URL由三件事决定:

  • ,其中SVC文件住
  • 名称和SVC文件本身

在你的情况的扩展服务器

  • 虚拟目录(和任何子目录)的名称,网址是

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

    因此,这引出了一个问题:

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

    UPDATE:

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

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

  • +0

    我已经发布了web服务标记和web.config,这有助于帮助。 我在DiscountASP.NET的控制面板中将应用程序定义为/ eLearning。我还将/ eLearning/Services定义为应用程序。 * .svc文件的名称是Learning.svc。 实际服务代码位于\ bin目录中,该目录位于\ eLearning中。 – Chris

    +0

    根据错误信息(缺少类型),我猜测这是你的最后一点 - 缺少程序集,即“bin”目录。 – Aaronaught

    +0

    但是,.NET框架内的任何程序集都不必包含在/ bin目录中,对吧?例如,在我的服务标记中,我为服务工厂使用“System.Data.Services.DataServiceHostFactory”。这是否意味着System.Data.Services.dll必须包含在/ bin目录中? – Chris