.net - 找不到WCF合约名称 'IMyService'?

标签 .net wcf exception

The contract name 'IMyService' could not be found in the list of contracts implemented by the service 'MyService'.. ---> System.InvalidOperationException: The contract name 'IMyService' could not be found in the list of contracts implemented by the service 'MyService'.

这让我发疯。我有一个在我的开发计算机上运行的 WCF Web 服务,但是当我将其复制到我用于测试的虚拟机时,我收到错误,该错误似乎表明我没有实现该接口(interface),但它并没有使有道理,因为该服务确实可以在我的 Windows XP IIS 上运行。虚拟机使用Windows Server 2003 IIS。有什么想法吗?

这里需要注意的一件事是,即使我只是尝试作为客户端在 Web 浏览器中访问该服务,我的虚拟机上也会出现此错误。

注意:我使用的是principalPermissionMode="UseWindowsGroups",但这在我的本地计算机上不是问题。我只是将自己添加到适当的 Windows 组中。但我的虚拟机不走运。

配置:

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

最佳答案

[ServiceContract] 在我的案例中缺失。

关于.net - 找不到WCF合约名称 'IMyService'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/691746/

相关文章:

c# - 解决此错误需要进行哪些基本检查-找不到类型或 namespace 名称

c# - WCF websocket 在断开连接时不会关闭

c# - OutOfMemoryException,堆栈大小巨大,线程数量大

.net - 重构 Linq 表达式的选择部分?

c# - P4Api client.GetFileMappings 不返回分支文件的前导减号/破折号

C#:具有显式添加/删除的事件!=典型事件?

c# - 在 WCF 测试客户端中输入字节数组的值

python - 如何创建具有多种原因的 python 异常?

android - Android 设备上的 Http 连接被拒绝

postgresql - 在 postgresql 函数中抛出异常