none
System.InvalidOperationException: 在服务“Service1”实现的协定列表中找不到协定名称“ApprovalMessageContractLibrary.IMetadataExchange”。 RRS feed

  • 问题

  • 本人正在学习WCF和WF,尚未入门,在将文档审批过程示例由C#转换为VB的过程中,WCF服务主机出现如题错误,这是怎么回事呢?

    项目的根命名空间,由Microsoft.Samples.DocumentApprovalProcess,改为默认的了。

    '-------------ApprovalMessageContractLibrary 中自动自成的Service类,未加改动:

    Public Class Service1
        Implements IService1

        Public Function GetData(ByVal value As Integer) As String Implements IService1.GetData
            Return String.Format("You entered: {0}", value)
        End Function

        Public Function GetDataUsingDataContract(ByVal ApprovalData As ApprovalDataTypes) As ApprovalDataTypes Implements IService1.GetDataUsingDataContract
            If ApprovalData Is Nothing Then
                Throw New ArgumentNullException("composite")
            End If
            If ApprovalData.BoolValue Then
                ApprovalData.StringValue &= "Suffix"
            End If
            Return ApprovalData
        End Function

    End Class

    '------------ApprovalManager中的App.config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
        <add key="ClientSettingsProvider.ServiceUri" value="" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
        <membership defaultProvider="ClientAuthenticationMembershipProvider">
          <providers>
            <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
          </providers>
        </membership>
        <roleManager defaultProvider="ClientRoleProvider" enabled="true">
          <providers>
            <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
          </providers>
        </roleManager>
      </system.web>
      <!-- 部署服务库项目时,必须将配置文件的内容添加到
      主机的 app.config 文件中。System.Configuration 不支持库的配置文件。-->
      <system.serviceModel>
        <services>
          <service name="ApprovalMessageContractLibrary.Service1">
            <endpoint address="" binding="basicHttpBinding" contract="ApprovalMessageContractLibrary.IService1">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="ApprovalMessageContractLibrary.IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8733/Design_Time_Addresses/ApprovalMessageContractLibrary/Service1/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- 为避免泄漏元数据信息,
              请在部署前将以下值设置为 false -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
              <!-- 要接收故障异常详细信息以进行调试,
              请将以下值设置为 true。在部署前设置为 false
                以避免泄漏异常信息-->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>


    韩立学






    2015年4月9日 1:58

答案

全部回复