简体   繁体   English

如何使用 Python 反序列化数据库中的 C# object?

[英]How do you deserialize a C# object in database using Python?

We have an application that takes user data in C#, serializes it and puts it in a database.我们有一个应用程序在 C# 中获取用户数据,将其序列化并将其放入数据库中。

I need to write an admin program in Python that takes that value and deserialize it.我需要在 Python 中编写一个管理程序来获取该值并对其进行反序列化。 I've tried using Pickle but I believe the format is different, because I keep getting errors.我尝试过使用 Pickle,但我相信格式不同,因为我不断收到错误。

Is this doable?这是可行的吗?

Thanks!谢谢!

Edit 1: The type is binary -- here is the c# code that constructs it (where o is the object):编辑 1:类型是二进制的——这里是构造它的 c# 代码(其中 o 是对象):

        using  ( MemoryStream stream = new MemoryStream( ))
        {
            IFormatter myformatter = new BinaryFormatter();
            myformatter.Serialize(stream, o);
            return stream.ToArray();}

Use IronPython so you can just use the .NET framework, like you did to save the data.使用IronPython ,这样您就可以像保存数据一样使用 .NET 框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将json反序列化为属性名称开头带有“ @”的C#对象? - How do you deserialize json into a C# object that has “@” at the beginning of the property names? 如何使用c#从数据库返回一个整数? - How do you return an integer from a database using c#? 如何使用C#中的流读取器有效地反序列化带有嵌套对象的JSON对象? - How do I efficiently deserialize a JSON object with nested objects using a stream reader in C#? 如何在 C# .NET 中反序列化复杂的 JSON 对象? - How do I deserialize a complex JSON object in C# .NET? 如何反序列化 C#.Net Core 中的分页 object - How do I deserialize a paging object in C# .Net Core 如何反序列化为现有对象 - C# - How do I deserialize into an existing object - C# 如何使用 c# 反序列化复杂的 JSON 对象? - How to Deserialize complex JSON object using c#? 如何使用 Z3501BB093D363810B671059B 属性将 XML 反序列化为 C# Object 属性 - How to Deserialize XML to C# Object using XML attributes 如何使用VB.net或C#以面向对象的方式管理跨插入的数据库连接和事务? - How do you manage database connections and transactions across inserts in an Object Oriented way, using VB.net or C#? 使用C#反序列化复杂的JSON对象 - Deserialize complex JSON object using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM