【问题标题】:How do I configure the type provided as the Service attribute value in web.config?如何在 web.config 中配置作为服务属性值提供的类型?
【发布时间】:2013-03-07 16:55:35
【问题描述】:

我在我的 web.config 文件的 <system.serviceModel> 标记中配置了以下内容:

<system.serviceModel>
  <bindings/>
  <client/>
  <behaviors>
    <serviceBehaviors>
      <behavior name="serviceTypeBehaviors">
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  </serviceHostingEnvironment>
  <services>
    <service behaviorConfiguration="serviceTypeBehaviors" name="AcpService.MainFrameData">
      <endpoint address="" binding="basicHttpBinding" contract="AcpService.IMainFrameService" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
  </services>
</system.serviceModel>

我的服务的 XML 是这样的:

<%@ ServiceHost Language="C#" Debug="true" Service="AcpService.MainFrameData" CodeBehind="MainFrameWoData.svc.cs" %>

我的应用程序正在 默认网站 的应用程序池中运行,其中 Enable 32-Bit Applications 设置为 True(因为服务使用一些旧的数据访问库)。

当我运行它时,我得到了这个错误:

“/mainframe”应用程序中的服务器错误。

找不到类型“AcpService.MainFrameData”,在 ServiceHost 指令中作为 Service 属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供。

异常详情: System.InvalidOperationException:类型“AcpService.MainFrameData”,作为 ServiceHost 指令中的服务属性值提供,或在配置元素 system.serviceModel/serviceHostingEnvironment/serviceActivations 中提供找不到。

版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.272

我几乎修改了我的&lt;serviceHostingEnvironment&gt; 标记以包含&lt;serviceActions&gt; 参数,但我真的不明白该怎么做。

这是我走了多远:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
  <serviceActivations>
    <add factory="System.ServiceModel.Activation.ServiceHostFactory"
      relativeAddress="~/mainframe/MainFrameWoData.svc"
      service="AcpService.MainFrameData" />
  </serviceActivations>
</serviceHostingEnvironment>

我不确定我是否正确执行此操作,并且我不知道要为 service= 参数插入什么内容。 MSDN 上的 信息似乎没用。

这个项目最初有一个不同的名称,但我不得不为服务添加功能。我不想编辑活动服务,因为这样做意味着所有试图访问我们内部网络上的数据的员工现在都会遇到该错误,因此该服务被复制到一个新项目中,并且正在发布到我们服务器上的新位置。我最好的猜测是web.config 文件(或???)中的某些内容与项目本身的内容不匹配。

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: asp.net visual-studio-2010 wcf c#-4.0


    【解决方案1】:

    看起来我的项目需要 MainFrameService 而不是 MainFrameData

    我开始删除这篇文章,但是……谁知道呢?也许其他人可以从中得到一些用处。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      相关资源
      最近更新 更多