C#
每次我运行我的色情图我都会得到这样的例外:
但是,当我在调试模式下运行时,没有异常,程序运行良好,我能做什么呢?
注意:我在项目中的任何地方都不使用()
编辑:好的,下面是详细信息中的代码:如果有人知道如何使用protoBuff,并且知道这个问题.
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> ProtoBuf.
我使用protobuf-net进行序列化和反序列化。
我所遵循的方法是创建一个RuntimeTypeModel,并添加需要序列化或支持序列化的所有类型。在添加所有类型之后,我使用TypeModel.Compile()来获得性能优势。
当一个类实例被序列化并作为blob保存到数据库中时,我就能够在从数据库获取时反序列化它。但是,当我更改机器并尝试反序列化时,我得到的是ArgumentException类型的token
at ProtoBuf.ProtoReader.EndSubItem(SubItemToken token, ProtoReader reader) in c:\Dev\pr
我不习惯使用Protobuf-net进行一些序列化,并获得以下代码片段的折叠错误:
错误:
动态类型不是契约类型: TestType[]
片段:
using System.IO;
namespace QuickStart
{
class Program
{
static void Main()
{
//FileAccess.ShowFileAccess();
//Sockets.ShowSockets();
var dto = new DataTransferTyp
我们有以下类作为ADO.NET提供程序的一部分,使用WCF在网络上运行。
[KnownType(typeof(AdoServiceCommandExecutionScalarResult))]
[DataContract(Namespace = Namespaces.SoafXmlNamespace)]
public class AdoServiceCommandExecutionResult
{
}
[DataContract(Namespace = Namespaces.SoafXmlNamespace)]
public class AdoServiceCommandExecutionSc
我正在接收kafka上的protobuf消息,使用者被配置为使用
value.deserializer = org.apache.kafka.common.serialization.StringDeserializer
如果通过传递反序列化事件字符串的字节数组来使用com.google.protobuf.Parser的com.google.protobuf.Parser方法,则该方法引发以下异常:
com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input en
我使用protobuf将一些大的Dictionary序列化到磁盘上,磁盘上的文件大小为450 on。
通常,代码在OutOfMemoryException中失败
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at ProtoBuf.BufferPool.ResizeAndFlushLeft(Byte[]& buffer, Int32 toFitAtLeastBytes, Int32 copyFromIndex, Int32 copyB
我试图向子进程发送一个protobuf消息。反序列化在父级中运行良好,如下所示:
var deserialized = Serializer.Deserialize(typeof(ChildProcessTestMessage), new MemoryStream(new byte[] { 8, 1 }));
[ProtoContract]
public class ChildProcessTestMessage
{
[ProtoMember(1)]
public int Int { get; set; }
}
我在这个示例代码和子进程中硬编码了字节0x0801,以确保字节是
有一些逻辑可以使用protobuf将DataContainer<BaseClass>类型的数据存储到某个存储库中。假设我需要创建新的DerivedClass,所以所有新的DataContainer<DerivedClass>实例都将被正确序列化,但是为了实现备份兼容性,我希望可以选择将一些以前保存的数据反序列化为DerivedClass,而无需更改存储库中的任何数据。
class Program
{
static void Main(string[] args)
{
var baseObject = new BaseClass(
是否应该支持序列化PropertyInfo?如果不是,最好的解决方法是什么?我知道可以序列化类型(这是受支持的),然后通过它的属性来查找属性-想象一下查找可能会很昂贵。
附注:PropertyInfo用于实现类似于DataLoadOptions.LoadWith 的功能。
using System.IO;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ProtoBuf;
[ProtoContract]
public class A
{
[ProtoMember(1)
我正在将protobuf反序列化调用从泛型调用转换为指定类型。
using var memStream = new MemoryStream(bytes);
var result = Serializer.Deserialize<T>(memStream);
至
using var memStream = new MemoryStream(bytes);
var result = Serializer.Deserialize(memStream, type);
我得到了一个例外
ProtoBuf.ProtoException: Invalid wire-type (Fixed64)
我注意到,当我在多线程上下文中使用protobuf-net时,它往往会间歇性地失败,并出现以下错误:
System.TimeoutException: Timeout while inspecting metadata; this may indicate a deadlock.
This can often be avoided by preparing necessary serializers during application initialization, rather than allowing multiple threads to perform the initial m
我一直在尝试在MonoTouch中使用protobuf-net,但我不知道如何使用,尽管我听说这是可能的,但我还没有找到任何实际有效的教程或示例。
Marc Gravell 证实,它确实可以在MonoTouch上工作。我还浏览了他在这篇文章中陈述的两个人的博客,但我没有找到任何与protobuf相关的东西。
由于在这个问题上没有线索,我决定下载protobuf-net并尝试一下。因此,我创建了以下对象用于测试:
[ProtoContract]
public class ProtoObject
{
public ProtoObject()
{
}
[Proto
是否可以将具有属性的聚合类型反序列化为作为引用的抽象基类型,请参阅Aggregate.Base?如果没有,什么是最好的解决办法?
[ProtoContract]
[ProtoInclude(1, typeof(Derived))]
public abstract class Base { }
[ProtoContract]
public class Derived : Base
{
[ProtoMember(1)]
public int SomeProperty { get; set; }
}
[ProtoContract]
public class Aggregate
{
我有一个使用protobuf序列化的嵌入式C#应用程序。当序列化大约50个条目的集合时,它会抛出一个StackOverflowException,只能在运行WinCE的设备上进行复制。堆栈大约有600个条目深,结尾如下:
at ProtoBuf.Meta.RuntimeTypeModel.GetKey(Type type, Boolean demand, Boolean getBaseKey)
at ProtoBuf.Meta.ValueMember.TryGetCoreSerializer(RuntimeTypeModel model, DataFormat dataFormat, T
我们目前面临的问题是,我们希望通过使用Wp7将目前运行在Android (Monodroid)和MonoTouch上的应用程序移植到IOS。
这不是问题所在,但使用protobuf-net框架反序列化数据经常失败,只有以下例外:
ProtoBuf.ProtoException: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354
at P