.net – WCF Contract Name ‘IMyService’ could not be found

exception handlingnetwcf

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>

Best Answer

[ServiceContract] was missing in my case.

Related Topic