Friday, August 21, 2009

Exception when implement function overloading in WCF

Hi Folks,

If you tried to develop a simple WCF function, and you tried to write in your WCF 2 overloading functions in WCF, you will not be able to deploy your serivce and the clients will get an exceptions.

The solution: give Aliases to the overloaded functions in the WCF service.

Code :


public interface IMyWCFSvc
{
[OperationContract(Name="GetCustomerById")]
string GetCustomerInfo( int CustId);

[OperationContract(Name="GetCustomerByEmail")]
string GetCustomerInfo( string CustomerEmail);
}

The proxy when you reference to your serivce, will create 2 methods with the Alias names and not with the actual overloaded name in C# code.

Hope this helps.


Regards,
Mostafa arafa
Post a Comment