Hi all. I just started to learn how to use WCF. I encouter the compiling errors when tring to use System.Action to call the WCF service. Here is the code that calls the generic function:
In UserServiceProxy.cs:
new ClientFactory().TryExecuteAndClose(delegate(UserServiceClient client)
{
UserEntity entity=client.GetCurrentUser(true)
},uncompressed);
Then in ClientFactoryBase.cs, I have:
public void TryExecuteAndClose<Client> (Action<Client> action, string bindingType) where Client: ICommunicationObject, new()
{
var client=default(UserServiceClient);
if(typeof(Client).Name=="UserServiceClient")
{
if(bindingType.Equals("uncompressed"))
client=new UserServiceClient("basic");
else
client = new UserServiceClient("secure");
}
action(client); //##############this is where I got compile error.
client.Close();
}
The 2 errors that I got are complaining about "delegate System.Action<Client> has some invalid arguments" and "Cann't convert UserServiceWcf.UserServiceClient to Client".
Could someone help me on how to fix the errors? Thanks a lot.