polenter / SharpSerializer

SharpSerializer can serialize types like: multidimensional array, nested array, array-of-arrays, polymorphic object (where value is inherited from the property type), generic type, generic listing (i.e. dictionary, collection) and many more, with a single line of code
https://www.sharpserializer.net
Other
114 stars 28 forks source link

No parameterless constructor defined for this object. #1

Open xbrady opened 7 years ago

xbrady commented 7 years ago

When I try to deserialize a complex object I'm getting the following error: No parameterless constructor defined for this object.

I obviously have a class somewhere without a parameterless constructor, the problem is I don't know which one. Can this please be updated to include the type that it is failing to create? Call stack: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

gashupl commented 4 years ago

Had the same error. Not sure why it is happening becuase the list of objects I'm trying to deserialize may be created with parameterless constructor. Also the objects inside the list may be created using the constructor without parameters. More detailed information inside the error message would be really appreciated.

Meekohi commented 1 year ago

I'm getting this error on an extremely simple object that clearly has a parameterless constructor... I'm lost as to what the issue is, not sure this library actually works anymore.

technyon commented 8 months ago

I had the exact same issue. I proceeded to checkout the source code and directly include it in my (.NET 8) solution, and referenced it it the relevant project. The problem just went away on it's own.

Either

Either way, if you want to fix this problem, just directly include the sources in your solution/project.

Note: Could be related to issues #19 and #21