4
votes

I am sending a generic parameter in my Service Fabric application method via service remoting.

my Interface is as follows:

public interface IMyServiceRemoting : IService
{
   Task<String> GetMessageFromServer<T>(T hint)// a hint could be of byte[] or string or any object
}

While I am getting

System.ArgumentException: "The service interface 'ServiceRemoting.Interfaces.IMyServiceRemoting`1[[System.Object, mscorlib, version = 4.0.0.0, Culture=neutral, publicKeyToken=b77a5c561934e089]]'is using generic. Generic interface cannot be remoted".

I am unable to understand why I can't use generics. Kindly help with proper explanation.

2

2 Answers

4
votes

You simply can't. It's not possible to do that, as soap does not support this. See this article, which mentions how to get around generics, by creating an intermediate local object that is called and casts the object before calling the WCF operation.

1
votes

This question was asked before. The answer is from an SF team member.

So in your case, no, generics are not yet supported. But this is a limitation of that specific service communication stack, not of services in general, and of course you can use any communication stack you want