Reputation: 355
I'm encountering a TypeLoadException when I use a strongly typed hub. My interface is:
public interface IClientCallback
{
void callback<T>(T msg, string eventType);
void test(string msg, string eventType);
}
All the methods are inside a single interface, and the interface does not inherit from any other interface.
My Hub class is:
public class ServiceHub : Hub<IClientCallback>
{
public static readonly string ServiceHubName = "ServiceHub";
public void Register(string name, string eventType)
{
Clients.All.test("hello", "world");
}
}
When I use my client app to invoke the Register method on the hub, on the Hub application I receive an exception when it is at Clients.All.test(...):
TypeLoadException Method 'callback' in type 'Microsoft.AspNet.SignalR.Hubs.TypedClientBuilder.IClientCallbackImpl' from assembly 'Microsoft.AspNet.SignalR.Hubs.TypedClientBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
I haven't been able to narrow down what exactly is causing this exception to be thrown. A little help or suggesting would be greatly appreciated.
Upvotes: 7
Views: 1155
Reputation: 5082
It took couple hours of debugging to work out that the problem is in generic method definition. It seems like it simply doesn't supported.
So as a workaround it's possible to change the type of msg
parameter to object
and make callback
method not generic. After this change everything should be working.
I wish Microsoft at least would add a warning about this limitation to the documentation.
Upvotes: 6
Reputation: 1620
Seems like SignalR is using reflectionto find wich classes implements IClientCallback
to instantiate it, but found nothing
Upvotes: 0