我在VS2010中创建了一个带有.Net 4设置的示例应用程序。我正在尝试ProtoBuf扩展方法。但是,每当我尝试调用GetValue扩展时,它都会抛出一个异常:
Method or operation is not implementedStackTrace:
at ProtoBuf.ExtensibleUtil.GetExtendedValues[TValue](IExtensible instance, Int32 tag, DataFormat format, Boolean singleton, Boolean allowDefinedTag)
at ProtoBuf.Extensible.TryGetValue[TValue](IExtensible instance, Int32 tag, DataFormat format, Boolean allowDefinedTag, TValue& value)
at ProtoBuf.Extensible.TryGetValue[TValue](IExtensible instance, Int32 tag, DataFormat format, TValue& value)
at ProtoBuf.Extensible.GetValue[TValue](IExtensible instance, Int32 tag, DataFormat format)
at ProtoBuf.Extensible.GetValue[TValue](IExtensible instance, Int32 tag)
at PhoneBookData.PhoneBookSerializer.Serialize(PhoneBookProto phData) in E:\project\PhoneBook\Source\PhoneBookData\PhoneBookSerializer.cs:line 14
at ConsoleApplication1.Program.Main(String[] args) in E:\project\PhoneBook\Source\ConsoleApplication1\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()下面是我的Proto类与扩展支持。
[ProtoContract]
public class PhoneBookProto : Extensible
{
[ProtoMember(1, IsRequired=true)]
public string Name { get; set; }
[ProtoMember(2)]
public string Email { get; set; }
[ProtoMember(3)]
public AddressProto Address { get; set; }
[ProtoMember(4,IsRequired=true)]
public string PhoneNumber { get; set; }
}
[ProtoContract]
public class AddressProto
{
[ProtoMember(1)]
public string Line1 { get; set; }
[ProtoMember(2)]
public string Line2 { get; set; }
}我做错什么了。我有参考最新的原型版本(561)可供下载。下面是我不断崩溃的代码。
Extensible.AppendValue<int>(phData, 5, 10);
Extensible.GetValue<int>(phData, 5);编辑其他旧版本的protobuf也给了我同样的例外
发布于 2012-08-05 17:37:23
确实如此。自v2重写以来,扩展数据是最后丢失的部分之一。正如您所看到的,它是路线图的下一个,但从实用的角度(时间可用性等),我必须首先对最常见的.NET场景进行优先级排序。扩展数据并不是最常见的用法。V1有一个完全工作的扩展数据API,r280 (IIRC)仍然可用。
一旦我进入到这一点,我不认为(写过一次)它是一个巨大的工作,所以我希望它将很快在建设。
编辑:这应该是从r565开始提供的
https://stackoverflow.com/questions/11818109
复制相似问题