What was wrong with this MS sample?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, guys,

When playing with the sample source code for WCF service at
http://msdn2.microsoft.com/en-us/library/ms730935.aspx, I got an error:

The contract type Microsoft.ServiceModel.Samples.CalculatorService is not
attributed with ServiceContractAttribute. In order to define a valid
contract, the specified type (either contract interface or service class)
must be attributed with ServiceContractAttribute.

at the line

NetTcpBinding portsharingBinding = new NetTcpBinding();
hostDefault.AddServiceEndpoint(
typeof(CalculatorService),
portsharingBinding,
"net.tcp://localhost/MyService");

I did not modify anything. What was wrong here?

Thanks a lot
 
It should work if you change typeof(CalculatorService) to
typeof(ICalculatorService) in below line of code
hostDefault.AddServiceEndpoint(typeof(CalculatorService),
portsharingBinding,"net.tcp://localhost/MyService");
 
Back
Top