SignalR 2 客户端 - 数据序列化问题

SignalR 2 Client - Data Serialization Issues

I am currently developing a Visual Studio VSIX extension with SignalR support and I am 运行 into a st运行ge issue.

Here is the strongly-typed hub code:

public interface ISyncClient
{
    void SelectionChanged(SelectionChangedMessage message);
}

public class SyncHub: Hub<ISyncClient>
{
    public void SelectionChanged(SelectionChangedMessage message)
    {
        Clients.Others.SelectionChanged(message);
    }
}

And here is the message class:

public class SelectionChangedMessage
{
    [JsonProperty("ss")]
    public int SelectionStart { get; set; }

    [JsonProperty("se")]
    public int SelectionEnd { get; set; }
}

The hub and the client communicate properly. On the client I have the following code:

proxy.On("selectionChanged", m => { var selectionStart = m.ss; });
proxy.On<SelectionChangedMessage>("selectionChanged", m => { var selectionStart = m.SelectionStart; });

The first handler receives the dynamic object and the ss 属性 (SelectionStart) is present. The second handler however, has the SelectionStart 属性 with a default value.

The messages, which are passing through the hub have their values set, but whenever the client tries to deserialize the message to the concrete message type it fails.

Somehow the client can't properly deserialize the JsonProperty attributes.

The client and the server are 运行 SignalR 2.2.1 with Newtonsoft.Json 9.0.1.

The same code works with a SignalR 2.2.1 client and a SignalR 0.1.0 Server from aspnetmaster 运行 on ASP.NET Core.

Has anyone else 运行 into similar issues?

Edit

I did a clean rebuild and made sure that all projects use the same version of Newtonsoft.Json. I also reset the Visual Studio Experimental instance and all started working.

我进行了彻底的重建,并确保所有项目都使用相同版本的 Newtonsoft.Json。我还重置了 Visual Studio 实验实例,一切都开始工作了。