1
我在.Net 4設置的VS2010中創建了一個示例應用程序。我正在嘗試ProtoBuf-Net擴展方法。然而,當我嘗試調用的GetValue extention,它拋出一個異常,說Protobuf-Net擴展方法不斷拋出異常
Method or operation is not implemented
堆棧跟蹤:
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()
下面是我的原班與Extention支持。
[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; }
}
我做錯了什麼。我參考了可供下載的最新protobuf版本(561)。下面是我的代碼不斷崩潰。
Extensible.AppendValue<int>(phData, 5, 10);
Extensible.GetValue<int>(phData, 5);
編輯 其他老版本的protobuf也給了我同樣的異常
謝謝!我試過r280 NET 3.0版本。它似乎在工作。 – SysAdmin 2012-08-05 17:45:52
如果你可以更新維基頁面的擴展名,這將有助於其他的太 – SysAdmin 2012-08-05 17:49:44
@SysAdmin嘗試r565,只是更新 – 2012-08-08 10:22:58