koszeggy / kgysoft.corelibraries Goto Github PK
View Code? Open in Web Editor NEWKGy SOFT Core Libraries features high-performance and handy general libraries.
Home Page: https://kgysoft.net/corelibraries
License: Other
KGy SOFT Core Libraries features high-performance and handy general libraries.
Home Page: https://kgysoft.net/corelibraries
License: Other
Hello, how do I deserialize a data structure in c++ that I serialized using the BinarySerializer.Serialize. Thanks
So, I'm trying the default minimal code from your example to serialize MyClass
back and forward. The serialization passes, however on deserialization I've got exception cited in the title.
I just want to make sure that I understand this correctly - Do I actually need to explicitly write all the types used in MyClass
structure, or write custom code which does it? That sounds insane. Why do you need that if I already gave the MyClass
to Deserialize()
method? Shouldn't all types used within MyClass
be expected implicitly?
I understand that there are cases like having interface properties ISomething xxx
where you would want me to specify that a ConcreteSomething
could be used but I don't have that in my case. I have ~18 custom types used in MyClass
already and I consider it a very trivial structure... Do you really want me to type typeof(XXX),...
for all those types as method's parameters?
The constructor of BinarySerializationFormatter crashes in x86 projects with this exception:
AccessViolationException
Fatal error. 0xC0000005
at DynamicEnumComparerInt32`1[[KGySoft.Serialization.Binary.BinarySerializationOptions, KGySoft.CoreLibraries, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b45eba277439ddfe]].ToUInt64(KGySoft.Serialization.Binary.BinarySerializationOptions)
Add this property to the csproj:
<PlatformTarget>x86</PlatformTarget>
Full Example:
KGySoftX86.zip
I have the following Situation:
I had an old .NET Framework 4.5.2 application that in the past stored the following objects serialized by the native BinaryFormatter in a SQL database:
[Serializable]
[DataContract]
public class MyClass
{
[DataMember]
private ConcurrentDictionary<DaylightFactorType, double[]> _values = new();
}
Now I have upgraded the application to ASP.NET 8 and when I now try to load and deserialize the data using the native BinaryFormatter, I get the following exception:
Type 'System.Collections.Concurrent.ConcurrentDictionary`2[[MyClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Double[], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' in Assembly 'System.Collections.Concurrent, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
So I thought I'd use the KGySoft.CoreLibraries to deserialize the data, because it should be possible to deserialize types that are no longer marked as [Serializable]
.
But the problem now is that I always get null
back from the method BinarySerializer.DeserializeFromStream<T>(stream)
.
How can I solve this? Because the DB is actually read-only for me, and it would be a big effort to fill the database again.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.