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

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.