对象实例化时调用的目标抛出异常

Exception has been thrown by the target of an invocation upon object instantiation

这个问题我苦思了一个下午都无济于事。我需要将 SignalR 集成到 SharePoint 场解决方案中 (http://sharepoint-community.net/profiles/blogs/using-signalr-2-2-in-a-sharepoint-2013-farm-solution)。集成本身不是这里的问题,一旦我可以在使用 JS 使用自定义 PersistentConnection 时看到日志事件。我的公司使用基于 HttpHandlers 的服务层响应自定义后缀并执行一些反射以了解根据 url 模式调用哪个方法。一切都很好!问题出现在我的服务代码中,它将消息发送到自定义 PersistentConnection 以便它可以广播到所有连接的客户端,我实例化一个 Microsoft.AspNet.SignalR.Client.Connection 对象。

using Microsoft.AspNet.SignalR.Client;
// other usings
[Route] // Custom attribute
public object MyCustomServiceMethod() {
    try // LINE NUMBER: 5
    {
        // broadcast message to all connected clients
        var url = "CONNECTION URL"; // LINE NUMBER 8
        var connection = new Connection(url); // LINE NUMBER: 9
        connection.Start().Wait(); // LINE NUMBER: 10
        connection.Send(CUSTOM_MODEL_HERE).Wait(); // LINE NUMBER: 11

        return Ok(new // LINE NUMBER: 13
        {
            Status = "SOME STATUS CODE HERE",
            Data = SOME DATA HERE
        });
    }
    catch (Exception ex)
    {
       // some logging logic here
    }
}

问题是我得到一个 "Exception has been thrown by the target of an invocation." 异常并且执行没有 运行 MyCustomServiceMethod 方法。有趣的是,当我评论第 9、10 和 11 行时,执行完美地到达了第 13 e returns 行。我的 Sharepoint 项目针对 .Net 4.5 进行编译,因此我引用了 SignalR Client 的 4.5 版 (https://github.com/SignalR/SignalR/tree/dev/src/Microsoft.AspNet.SignalR.Client45)。当我不对上述行进行注释时,代码执行甚至没有到达自定义服务方法中第 5 行的断点。它在管道之前抛出异常。我在这里错过了什么?

提前致谢!

我找到了解决问题的方法!问题是我从直接从 github 下载的源代码生成了 Microsoft.AspNet.SignalR.Client.dll,因此生成的 dll 没有签名。一旦我从 nuget 下载 Microsoft.AspNet.SignalR.Client.dll,代码 运行 就完美了。