1

When i am serializing List of custom object. Non browsable fields are omitted in result.

it is example of propertry in C# 4.5

[DisplayName("G.Amt"), Browsable(false)]
public decimal GAmt { get{ return qty * rate; } } }

I want to include this property in xml output. Please suggest which attribute will work to do this.

Edit

I realize that browsable(false) is not cause to omit this property in xml output. Actually readonly properties omits in xml serialization.

Force XML serialization to serialize readonly property this question describes the actual problem and its solution. It seems that this question is duplicate. But in above described question provided solution is just a trick. Here i am asking for any attribute that can resolve this problem.

However in the above question @Marc Gravell answered to use [DataMember] attribute. But when i am using this, an error generated

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll

Additional information: Cannot deserialize type 'BusinessObject.SaleProductDetailBusinessObject' because it contains property 'GAmt' which has no public setter.

Please provide any attribute to resolve this issue.

Community
  • 1
  • 1
Haider Ali Wajihi
  • 2,756
  • 7
  • 51
  • 82

0 Answers0