Groups | Blog | Home
all groups > dotnet framework > june 2007 >

dotnet framework : What was wrong with this MS sample?



Andrew
6/14/2007 11:23:02 AM
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?

ravi kumar
6/22/2007 9:06:49 AM
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");


AddThis Social Bookmark Button