force-net / DeepCloner

Fast object cloner for .NET
MIT License
527 stars 72 forks source link

When Object have navigation property, DeepClone throw exception. #28

Open jiehanlin opened 2 years ago

jiehanlin commented 2 years ago

System.StackOverflowException:“Exception_WasThrown” on internal static Func<T, DeepCloneState, T> GetClonerForValueType().

force-net commented 2 years ago

Can you provide short example of code, which causes this error? Also, if it required, write dependent packages with version.

jiehanlin commented 2 years ago

When dbcontext proxycreationenabled set to true,The result is System.Data.Entity.DynamicProxies objects,so Exception_WasThrown.

force-net commented 2 years ago

Interesting situation. I'll try to reproduce. Cloning generated objects can be tricky.

jiehanlin commented 2 years ago

https://stackoverflow.com/questions/40509906/a-circular-reference-was-detected-while-serializing-an-object-of-type-system-da

It should be the same for DeepClone.

jiehanlin commented 2 years ago

https://github.com/jiehanlin/deepclonerdemo

the demo,console no exception,but webproject have exception.