What was wrong with this MS sample?

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
 
R

ravi kumar

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");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top