发布:2021/6/24 13:50:49作者:管理员 来源:本站 浏览次数:1955
这段代码:var commandMessage = new CommandMessage { CorrelationId = Guid.NewGuid() }; var json = JsonConvert.SerializeObject(commandMessage); var myCommandMessage = (CommandMessage)JsonConvert.DeserializeObject(json);
给出此错误消息:
Additional information: Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'QueueConnectionStringTester.CommandMessage'
这是CommandMessage类:
public class CommandMessage { public Guid CorrelationId { get; set; }
}
我在这里想念的是什么?
或者:
var myCommandMessage = JsonConvert.DeserializeObject<CommandMessage>(json);
要么:
var myCommandMessage = (CommandMessage)JsonConvert.DeserializeObject(json, typeof(CommandMessage));
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4