I created a sample application in VS2010 with .Net 4 setting. I am trying out the ProtoBuf-Net Extention methods. However, Whenever, I try to call GetValue extention, It throws an exception saying
Method or operation is not implemented
StackTrace:
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()
Below is my Proto class with Extention support.
[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; }
}
What am i doing wrong. I have reference the latest protobuf version (561) available for download. Below is my code which keeps crashing.
Extensible.AppendValue<int>(phData, 5, 10);
Extensible.GetValue<int>(phData, 5);
Edit the other older versions of protobuf also gives me the same exception