DataMember not found

As I did my research on this issue, I still could not solve my error Error 1 Could not find the name of the type or namespace DataMember (do you miss the using directive or the assembly reference?)

I came across a solution which says that I should reference System.Runtime.Serialization , but still I was out of luck, even if I add a link to it.

Here is my code:

using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; using System.Xml.Serialization; namespace WebServApp { [Serializable] public class Employee { [DataMember] public int EmpNo { get; set; } [DataMember] public string EmpName { get; set; } [DataMember] public int DeptNo { get; set; } [DataMember] public int Salary { get; set; } } } 

and this is the tutorial that I'm actually trying to execute: http://www.dotnetcurry.com/ShowArticle.aspx?ID=472

Can someone help me with this error?

+4
source share
2 answers

I solved the problem. I just deleted System.Runtime.Serialization in the links in the project explorer and added it while browsing, then it worked. Weird

0
source

Remove System.Runtime.Serialization from the code, then add from the menu > Project> Add Link ..>. Then add the code. it is working.

+17
source

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


All Articles