views:

5268

answers:

10

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.


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>


Thanks, Glen

A: 

Is the assembly with the interface visible to the application? Also, did you specify the namespace as part of the interface name in the config file?

casperOne
A: 

Do you have any authentication set up on your VM in IIS? Try setting it to anonymous and see if it runs.

bendewey
I tried anonymous and restarted iis. still same error. thx
M3NTA7
can you post your system.serviceModel config section?
bendewey
I've added the system.serviceModel to my post above. Please take a look.
M3NTA7
A: 

Ok, this doesn't really satisfy my question, but one way that I found to resolve it was to install .NET 3.5. because both of my other environments had 3.0.

So I really haven't determined why it would work in one environment and not the other, especially with that interface error.

Go figure?

M3NTA7
A: 

can you post code of your interface...? as normally this occurs if you haven't specified ServiceContract attribute in your Interface...

Usman Masood
A: 

Doesn't the contract attribute on the endpoint need to be the fully qualified namespace?

Garry
A: 

yes @Garry you are right. contract in endpoint should be fully qualified name

<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"      name="MyService" bindingName="basicHttpBinding" bindingNamespace="http://my.test.com"  contract="Namespace.IMyService">
Usman Masood
+1  A: 

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

masty
+2  A: 

[ServiceContract] was missing in my case....

leblanc meneses
+1  A: 

Hello All,

below link provide reason and resolution for of the error

http://aspdotnethacker.blogspot.com/2010/06/contract-name-could-not-be-found-in.html

sandeep
A: 

Thanks Usman Masood. It help me.