简体   繁体   English

将值“ AAAAAAAAB9c =”转换为“ System.Version”类型时出错。 路径“版本”

[英]Error converting value “AAAAAAAAB9c=” to type 'System.Version'. Path 'version'

Whenever I try to access my Azure Mobile Service table, I get the following error: 每当我尝试访问Azure移动服务表时,都会出现以下错误:

An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in mscorlib.ni.dll but was not handled in user code mscorlib.ni.dll中发生了类型为'Newtonsoft.Json.JsonSerializationException'的异常,但未在用户代码中处理

Additional information: Error converting value "AAAAAAAAB9k=" to type 'System.Version'. 附加信息:将值“ AAAAAAAAB9k =”转换为类型'System.Version'时出错。 Path 'version', line 19, position 27. 路径“版本”,第19行,位置27。

This is the line where this error occurred: 这是发生此错误的行:

await App.MobileService.GetTable<TodoItem>().InsertAsync(todoItem);

I don't actually need the version value in my table. 我实际上不需要表中的版本值。 This value is automatically generated by Azure. 该值由Azure自动生成。 Is there a way to force ignore the version value? 有没有办法强制忽略版本值?

This is the TodoItem definition: 这是TodoItem定义:

 public class TodoItem
    {
    public string Id { get; set; }
    public DateTime createdAt { get; set; }
    public DateTime updatedAt { get; set; }
    public Version version { get; set; }
    public bool deleted { get; set; }

    ... and so on...
}

Your TodoItem code is wrong. 您的TodoItem代码错误。 It should be something like: 应该是这样的:

[Version]
public string Version {get; set;}

Here [Version] references VersionAttrbute that is located in the Microsoft.WindowsAzure.MobileServices namespace. 这里[Version]引用位于Microsoft.WindowsAzure.MobileServices命名空间中的VersionAttrbute。

I would avoid using System.Version for this purpose. 我将避免为此目的使用System.Version System.Version is for numeric version values such as software releases that following this pattern: wxyz . System.Version用于数字版本值,例如遵循此模式的软件发行版: wxyz It looks like you are receiving a string that can't fit that, nor do I expect you to. 看来您收到的字符串不合适,也不希望您这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Version未序列化 - System.Version not serialized system.version超过3个小数点C# - system.version more than 3 decimal points c# 如何在实体框架6中将System.Version映射为复杂类型 - How to map System.Version as Complex Type in Entity Framework 6 使用System.Version进行通用版本控制 - Using System.Version for general purpose versioning sql server中System.Version的数据类型 - Datatype for System.Version in sql server 无法将类型&#39;System.Version&#39;隐式转换为&#39;System.Net.HttpVersion&#39; - Cannot implicitly convert type 'System.Version' to 'System.Net.HttpVersion' 使用被套。 Net Framework 生成错误:无法评估表达式“[System.Version]::Parse('')” - Using coverlet with. Net Framework generates an error: The expression "[System.Version]::Parse('')" canot be evaluated 为什么JSON字符串中的System.Version没有正确反序列化? - Why System.Version in JSON string does not deserialize correctly? 使用Entity Framework Code First将System.Version存储在数据库中 - Storing System.Version in database with Entity Framework Code First 为什么.NET System.Version &quot;2.0&quot; 与 &quot;2.0.0.0&quot; 不同? - Why is .NET System.Version "2.0" different from "2.0.0.0"?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM