ASP.NET VNext Class Library System.Runtime.Serialization

Trying to create a serializable class in ASP.NET vNext Class Library Project. Failed to assign attribute attributes of class [DataContract] or [DataMember]. Since I was just starting to learn vNext, so I'm a bit confused. If someone can guide me, am I doing the right thing or not. My little code example.

using System; using System.Runtime.Serialization; namespace Schlouds.Business.Entities { [DataContract] public class Student { [DataMember] public Guid StudentId { get; set; } } } 
+6
source share
3 answers

It seems you need to add " System.Runtime.Serialization " to " frameworkAssemblies ".

See an example project.json file:

 "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" } } 
+7
source

This is an unofficial API to map the old namespace to the new.

http://packagesearch.azurewebsites.net/

for these attributes you will need System.Runtime.Serialization.Xml 4.0.10-beta-22416 if you are using core

+3
source

You can use the Microsoft.AspNetCore.Mvc.Formatters.Json package (or Microsoft.AspNetCore.Mvc.Formatters.Xml ) from Nuget for the .net kernel.

0
source

Source: https://habr.com/ru/post/981555/


All Articles