0

Dynamic proxy will cause only XML serialization issues and not the Json serialization problem?

I m getting the below error when i try to do load the data in XML format

System.Data.Entity.DynamicProxies.UnAuthEventStatusTyp_3A9BA375F5B9150B33712F32AE9753F5944622B315D48B2167AD5D0FF8B38B11' with data contract name 'UnAuthEventStatusTyp_3A9BA375F5B9150B33712F32AE9753F5944622B315D48B2167AD5D0FF8B38B11:http://schemas.datacontract.org/2004/07/System.Data

For testing purpose, i disabled lazy loading and then i hosted my application. There were no issues if i try to do Json serialization but if i do XML serialization, its getting failed.

Update 1:

If i dont disable Lazyloading, then i get errors related to Dynamic Proxies even for JSON Serialization. So does that mean to overcome proxy serialization in Json is it merely enough to disable LazyLoading

P.S : Using DTO and proxy disabled, i was able to get around this problem but would like to understand the reasoning behind it

Update 2:

With Lazy Loading and without Lazy loading, in both cases, entity types showing as dynamic proxy types while debugging. But Json serialization works when i disable lazy loading. Means its able to serialize dynamic proxy entities.. Am i correct?

Below is a snapshot of error message which i get if i disable Lazyloading

"Self referencing loop detected for property 'UnAuthEventStatusType' with type 'System.Data.Entity.DynamicProxies.UnAuthEventStatusTyp

TechQuery
  • 253
  • 3
  • 17
  • Because the JSON serialization doesn't require a data contract? This depends on the serializers you use. Also, the exception message is incomplete. – Gert Arnold Oct 07 '15 at 18:20
  • @GertArnold I m not sure but i thought even JSON serailization will fail if it tries to serialize dynamic proxy objects – TechQuery Oct 07 '15 at 19:13
  • You can tell json.net to stop when a self referencing loop is detected: http://stackoverflow.com/a/25700715/2066026 – Herr Kater Jul 15 '16 at 09:50

0 Answers0