Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Contract Name 'IMyService' could not be found?

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

This is driving me crazy. I have a WCF web service that works on my dev machine, but when I copy it to a Virtual Machine that I am using for testing, I get the error that seems to indicate that I am not implementing the interface, but it does not make sense because the service does work on my windows xp IIS. the Virtual machine uses Windows Server 2003 IIS. Any ideas?

One thing to note here is that I get this error on my VM even while just trying to access the service in a web browser as the client.

Note: I am using principalPermissionMode="UseWindowsGroups", but that is not a problem on my local machine. I just add myself to the appropriate windows group. But no luck on my VM.

Config:

<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>
like image 505
M3NTA7 Avatar asked Mar 27 '09 22:03

M3NTA7


2 Answers

[ServiceContract] was missing in my case.

like image 106
Leblanc Meneses Avatar answered Nov 11 '22 06:11

Leblanc Meneses


@Garry (a bit late, I know)

If your ServiceContract attribute defines a ConfigurationName, this should be the value in the endpoint, not the fully qualified name. I just had this problem now as described by the OP, and this was the solution for me. Hope this helps someone else who stumbles across this.

like image 32
masty Avatar answered Nov 11 '22 05:11

masty