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

Upgrade from Framework 4.5 to .Net 6.0 deserializer exceptions #26

Closed oxbridgepentathlon closed 9 months ago

oxbridgepentathlon commented 2 years ago

I am in the process of upgrading my application from .Net Framework 4.5 to .Net 6.0 and at the same time SharpSerializer 2.20.0 to 3.0.2.

I have a couple of different object models which are persisted by the previous version which I need the new version to deserialise and I'm running into a couple of issues (different exception for each object model):

  1. In this case I get two inner exceptions:

    MissingMethodException: Constructor on type 'X.Y.Z.ApplicationSettings' not found.

AND

CreatingInstanceException: Error during creating an object. Please check if the type "SportGeek.Adjudicate.Support.ApplicationStateModel.ApplicationSettings, SportGeek.Adjudicate.Support, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" has a parameterless constructor, or if the settings IncludeAssemblyVersionInTypeName, IncludeCultureInTypeName, IncludePublicKeyTokenInTypeName are set to true. Details are in the inner exception.

  1. I'm getting:

    {"Could not load type 'System.RuntimeType' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.":"System.RuntimeType"}

Issue 1 is clearly stating which class it thinks does not have a parameterless constructor but in fact ApplicationSettings certainly does have a parameterless constructor (if it didn't then it wouldn't work with the old version). There is the hint to check Include_Name settings: the xml I am trying to deserialise does include "Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" and the new version is now just "1.0.0" but I have tried changing that manually with a find an replace and it has made no difference.

I think Issue 2 may indicate I have some .Net type in the serialised object model that now can't be deserialised in .Net 6 but I hope I'm wrong about that as I'd be a bit stuck! The object models are rather complex so just trying to track down what type was the problem would be tricky.

SanderVanDam commented 2 years ago

Same issue when upgrading from 3.01 to 3.02. workaround downgrade to 3.01?