locked
System.NotSupportedException: The invoked member is not supported in a dynamic assembly. I found a bug is there a work around ? RRS feed

  • Question

  • User687406232 posted

    Trying the Owin examples with Asp.net core on 4.61 and i get the following running from the console and VS . Any ideas ?

    il: Microsoft.AspNetCore.Server.WebListener.MessagePump[0]
    ProcessRequestAsync
    System.NotSupportedException: The invoked member is not supported in a dynamic assembly.
    at System.Reflection.Emit.InternalAssemblyBuilder.get_Location()
    at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.GetTypesSafe(Assembly a)
    at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
    at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.BuildHubsCache()
    at System.Lazy`1.CreateValue()
    at System.Lazy`1.LazyInitValue()
    at Microsoft.AspNet.SignalR.Hubs.ReflectedHubDescriptorProvider.TryGetHub(String hubName, HubDescriptor& descriptor)
    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
    at Microsoft.AspNet.SignalR.Hubs.DefaultHubManager.GetHub(String hubName)
    at Microsoft.AspNet.SignalR.Hubs.HubManagerExtensions.EnsureHub(IHubManager hubManager, String hubName, IPerformanceCounter[] counters)
    at Microsoft.AspNet.SignalR.Infrastructure.ConnectionManager.GetHubContext(String hubName)
    at SignalRChat.ChatHub.SendAll(String name, String message) in C:\src\cosmos\cosmos-livehole\Cosmos.LiveHoles.Read.WebApi\SignalR\ChatHub.cs:line 25

    ### Steps to reproduce
    public class ChatHub : Hub
    {
    public void Send(string name, string message)
    {
    // Call the broadcastMessage method to update clients.
    Clients.All.broadcastMessage(name, message);

    }

    static public void SendAll(string name, string message)
    {
    // Call the broadcastMessage method to update clients.
    // Clients.All.broadcastMessage(name, message);
    IHubContext context = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
    context.Clients.All.displayPoll();

    }
    }

    Call SendAll , GlobalHost.ConnectionManager.GetHubContext fails.

    Friday, July 7, 2017 10:25 AM

Answers

  • User687406232 posted

    OK i found it...  and will post a bug issue but id like to know if there are any work arounds ?

    The issue is it runs through this code in ReflectedHubDescriptorProvider 

                try
                {
                    return a.GetTypes();
                }
                catch (ReflectionTypeLoadException ex)
                {
                    _trace.TraceWarning("Some of the classes from assembly \"{0}\" could Not be loaded when searching for Hubs. [{1}]\r\n" +
                                        "Original exception type: {2}\r\n" +
                                        "Original exception message: {3}\r\n",
                                        a.FullName,
                                        a.Location,
                                        ex.GetType().Name,
                                        ex.Message);

    Get Types throws a ReflectionTypeLoadException on  Microsoft.GeneratedCode  ( which a lot of xml serializers bring in..) 

    when it tries to do a trace a lot of fields eg location also throw this exception...

    I here there was some older code that ignored which version was it ? I suspect if i call this method really early in startup it should build the cache before  it brings this assembly in can anyone confirm. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 9, 2017 2:04 AM