Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageJsonSerializer.DeserializeAsync 会抛异常 #7

Open
SunriseChen opened this issue Sep 30, 2017 · 1 comment
Open

MessageJsonSerializer.DeserializeAsync 会抛异常 #7

SunriseChen opened this issue Sep 30, 2017 · 1 comment

Comments

@SunriseChen
Copy link

SunriseChen commented Sep 30, 2017

在 v0.1.122 版本后,当调用 MessageJsonSerializer.DeserializeAsync() 方法的时候会抛出下面的异常:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'System.Threading.Tasks.Task<Newtonsoft.Json.Linq.JObject>' to 'System.Threading.Tasks.Task<object>' at CallSite.Target(Closure , CallSite , Object ) at Apworks.ObjectSerializer.DeserializeAsync(Byte[] data, CancellationToken cancellationToken) at Apworks.Serialization.Json.MessageJsonSerializer.<DeserializeAsync>d__4.MoveNext()

查看源码后应该是下面的代码引起的:
public virtual Task<dynamic> DeserializeAsync(byte[] data, CancellationToken cancellationToken = default(CancellationToken)) => Task.FromResult(Deserialize(data));
估计是 Task.FromResult() 不能处理 dynamic 类型引起的。

@daxnet
Copy link
Owner

daxnet commented Oct 22, 2017

是的,这个问题在之前的版本存在,原因是Deserialize返回的dynamic类型其实是JObject类型,它无法被反序列化成一个具体的对象模型。现在应该已经修复了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants