首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >找不到WCF合同名称'IMyService‘?

找不到WCF合同名称'IMyService‘?
EN

Stack Overflow用户
提问于 2009-03-27 22:56:40
回答 13查看 64.6K关注 0票数 53

在服务‘MyService’实现的约定列表中找不到约定名称'IMyService‘..-> System.InvalidOperationException:在服务'MyService‘实现的约定列表中找不到约定名称'IMyService’。

我都快疯了。我有一个可以在我的开发机器上工作的WCF web服务,但是当我将它复制到我正在用于测试的虚拟机时,我得到的错误似乎表明我没有实现该接口,但这没有意义,因为该服务在我的windows xp IIS上工作。虚拟机使用Windows Server 2003 IIS。有什么想法吗?

这里需要注意的一件事是,我在虚拟机上遇到了这个错误,即使我只是试图作为客户端在web浏览器中访问服务。

注意:我使用的是principalPermissionMode="UseWindowsGroups",但这在我的本地机器上不是问题。我只需将自己添加到适当的windows组中。但在我的虚拟机上没有运气。

配置:

代码语言:javascript
复制
<configuration>
    <system.serviceModel>
        <diagnostics>
            <messageLogging logEntireMessage="false" maxSizeOfMessageToLog="2147483647" />
        </diagnostics>
        <services>
            <service behaviorConfiguration="MyServiceBehaviors" name="MyService">
                <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"
                  name="MyService" bindingName="basicHttpBinding" bindingNamespace="http://my.test.com"
                  contract="IMyService">
                </endpoint>
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="basicHttpBinding" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxStringContentLength="2147483647" />
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="Windows" proxyCredentialType="None" />
                    </security>
                </binding>
            </basicHttpBinding>
            <netTcpBinding>
                <binding name="WindowsClientOverTcp" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxStringContentLength="2147483647" />
                </binding>
            </netTcpBinding>
            <wsHttpBinding>
                <binding name="wsHttpBinding" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </binding>
            </wsHttpBinding>
        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="MyServiceBehaviors">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceAuthorization principalPermissionMode="UseWindowsGroups"
                      impersonateCallerForAllOperations="false" />
                    <serviceCredentials />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>
EN

回答 13

Stack Overflow用户

发布于 2010-04-01 23:41:49

在我的案子里[ServiceContract]失踪了。

票数 106
EN

Stack Overflow用户

发布于 2010-03-23 12:21:34

@Garry (我知道,有点晚了)

如果ServiceContract属性定义了ConfigurationName,则这应该是端点中的值,而不是完全限定的名称。正如操作员所描述的那样,我现在遇到了这个问题,这就是我的解决方案。希望这篇文章能帮助其他偶然发现这篇文章的人。

票数 32
EN

Stack Overflow用户

发布于 2011-02-02 08:57:58

这是一个稍微不常见的解决方案,适用于我的情况,但也有相同的错误:

可以使用以下属性覆盖协定名称空间:

代码语言:javascript
复制
[System.ServiceModel.ServiceContractAttribute([...], ConfigurationName = "IServiceSoap")]
public interface ISomeOtherServiceName

这将需要:

代码语言:javascript
复制
<endpoint address="" binding="basicHttpBinding" contract="IServiceSoap" />

而不是通常的(namespace).ISomeOtherServiceName.

这可能是代码生成的结果,在我的例子中是WSCFBlue

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/691746

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档