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

Home Page:https://www.sharpserializer.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No parameterless constructor defined for this object.

xbrady opened this issue · comments

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)

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.

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.

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

  • it has been already been fixed in the meantime, but no new release has been pushed to nuget, or
  • some incompatibilities between the .NET version used for compiling for nuget and my .NET version cause this problem

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