我使用的是与protobuf网memcache的供应商protobuf网lib和我想要使用的memcache附加功能:
I'm using protobuf-net lib with protobuf-net memcache provider and I'm trying to use memcache append function:
var data = new ArraySegment<byte>(Encoding.UTF8.GetBytes("appendedString"));
var result = _memcache.ExecuteStore(StoreMode.Add, key, data);
和它抛出异常:
运行时遇到了致命的错误。该错误的地址 在0x63765a43,上线0xd58。错误code是0000005。本 错误可能是在CLR或在不安全或不可校验的错误 用户code部位。这个错误的常见来源包括用户 编组错误的COM-互操作或PInvoke的,这可能会损坏 叠加。
The runtime has encountered a fatal error. The address of the error was at 0x63765a43, on thread 0xd58. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
我已经做了一些调试,并找出发生时引发异常:
I've done some debug and find out place when that exception is raised:
/Meta/RuntimeTypeModel.cs:692: ((元类型)类型[关键])Serializer.Write(值,目标寄存器);
/Meta/RuntimeTypeModel.cs: 692: ((MetaType)types[key]).Serializer.Write(value, dest);
下面值
是ArraySegment我想设置为值, DEST
是ProtoBuf.ProtoWriter。
Here value
is that ArraySegment which I want to set as value and dest
is ProtoBuf.ProtoWriter.
有没有什么办法可以解决这个错误,或者,也许,我做错了什么。也许我只是单纯地需要存储不是一个ArraySegment,只是字符串,字符串追加给它呢?
Is there any way to fix that error or, maybe, I'm doing something wrong. Maybe I just simply need to store not an ArraySegment, but just string and append strings to it too?
推荐答案
嘿;老实说我从来没有测试过 ArraySegment&LT; T&GT;
- 尽管CLR团队的用心,它根本没有使用所有的东西。我可以在一个非常简单的测试重现这样的:
Heh; in all honesty I've never tested ArraySegment<T>
- despite the intentions of the CLR team, it simply isn't used all that much. I can reproduce this in a very simple test:
using ProtoBuf;
using System;
[ProtoContract]
class Foo
{
[ProtoMember(1)]
public ArraySegment<byte> Data { get; set; }
static void Main()
{
var obj = new Foo { Data = new ArraySegment<byte>(new byte[] { 1, 2, 3 })};
Serializer.PrepareSerializer<Foo>();
var clone = Serializer.DeepClone(obj);
}
}
我会加入到测试套件,并修复。
which I will add to the test suite, and fix.
现在,我建议:只存储字节[]
...(即不使用 ArraySegment&LT; T&GT;
)。这可能会定格在protobuf网的下一个版本。
For now, may I suggest: just store the byte[]
... (i.e. don't use ArraySegment<T>
). This will probably be fixed in the next build of protobuf-net.
相关推荐
最新文章