尝试在ASP.NET vNext类库项目中创建可序列化的类.无法提供我的课程项目[DataContract]或[DataMember]属性.当我刚开始探索vNext时,我有点困惑.如果有人可以指导我是否正在做正确的事.我的小样本代码.
using System; using System.Runtime.Serialization; namespace Schlouds.Business.Entities { [DataContract] public class Student { [DataMember] public Guid StudentId { get; set; } } }
解决方法
看来你必须将“System.Runtime.Serialization”添加到“frameworkAssemblies”.请参阅示例project.json文件:
"net45": { "frameworkAssemblies": { "System.Runtime.Serialization": "4.0.0.0" },"dependencies": { "System.Reflection": "4.0.10-beta-22416","System.Reflection.Extensions": "4.0.0-beta-22526","System.Reflection.Primitives": "4.0.0-beta-22526","System.Reflection.TypeExtensions": "4.0.0-beta-22526","System.Collections": "4.0.10-beta-22526","System.Collections.Specialized": "4.0.0-beta-22526","System.Linq": "4.0.0-beta-22526","System.Linq.Expressions": "4.0.0-beta-22526","System.Linq.Queryable": "4.0.0-beta-22526","System.Runtime": "4.0.20-beta-22526","System.Runtime.Serialization.Primitives": "4.0.0-beta-22526","System.Runtime.Serialization.Xml": "4.0.10-beta-22526","System.Runtime.Serialization.Json": "4.0.0.0-beta-22526" } }