【发布时间】:2020-03-29 16:16:00
【问题描述】:
我有很多课,其中一门如下
public class DeletePatientCommand
{
public int Id { get; set; }
}
我进行了以下 WCF 操作:
object command = JsonConvert.DeserializeObject(
"{\"DeletePatientCommand\":{\"Id\":5}}",
typeof(DeletePatientCommand));
对象已反序列化,但其Id 始终为0 而不是5。
【问题讨论】:
-
你有没有试过调试代码,因为我很确定
Assembly.GetType会抛出异常,因为you didn't specify the full name of the type。 -
嗨 Steven,我没有故意指定全名,因为我将我的类放在默认命名空间中。
-
请包含异常及其所有内部异常的完整堆栈跟踪。
-
没有抛出异常!
-
您是否尝试过发布
{"Id":5}而不是{"DeletePatientCommand":{"Id":5}}?