[ProtoMember(1)]
public string Date
{
get { return date; }
set { date= value; }
}
}
I have a variable
List<ProtoBlock> data = new List<ProtoBlock>();
// serialize works fine
using (Stream outfile = File.Open(path,
FileMode.OpenOrCreate))
{
ProtoBuf.Serializer.Serialize(outfile, data);
}
but when I deserialize it using
using (Stream inFile = File.OpenRead(path))
{
data =
ProtoBuf.Serializer.Deserialize<List<ProtoBlock>>(inFile);
}
I am getting the error "Unknown wire-type 7".
Can some one help me on this?
Thanks
Jeevan
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Thanks
On Dec 19, 5:09 pm, Marc Gravell <marc.grav...@gmail.com> wrote:
> Rechecked with Net20 from the r278 build, and it worked fine. Sorry to be a
> pain, but do you have a complete example that shows the issue?
>
> Marc
>
> 2009/12/19 Marc Gravell <marc.grav...@gmail.com>
>
>
>
>
>
> > OK; I'll re-check with the Net20 variant...
>
> > 2009/12/19 jeevankodali <jeevankod...@gmail.com>
>
> > Thanks for the reply. I used r278 and Net20 folder in that zip file.
>
> >> On Dec 18, 2:36 pm, Marc Gravell <marc.grav...@gmail.com> wrote:
> >> > Hmmm... that should work fine; there *was* a related bug in an early
> >> build,
> >> > but...
>
> >> > Can I check which version and framework you are using? I've checked on
> >> r275,
> >> > and it works fine "as is", for both empty lists and some arbitrary data
> >> I
> >> > made up.
>
> >> > Sorry for the delay, btw - seasonal break, etc...
>
> >> > Marc Gravell (protobuf-net)
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "Protocol Buffers" group.
> >> To post to this group, send email to prot...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> protobuf+u...@googlegroups.com<protobuf%2Bunsubscribe@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/protobuf?hl=en.
>
> > --
> > Regards,
>
> > Marc
>
> --
> Regards,
>
> Marc- Hide quoted text -
>
> - Show quoted text -
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
This is what I did which caused this:
1. First I stored a dictionary, key is int and value is a list into
the proto file and loaded this data - this step was fine.
2. Next I changed my code to store just list instead of dictionary in
the same file - store was successful
3. I tried to load this new file (which was the same name and location
as the original file with dictionary), I was getting the error.
But when I deleted the original file and reran the code (which was
storing the list), everything was fine.
Here is the code:
[ProtoContract]
public class ProtoTestClass
{
private string _id;
[ProtoMember(1)]
public string Id
{
get { return _id; }
set { _id = value; }
}
}
// below code throws error because I am using the same file
private static void ProtoTest()
{
List<ProtoTestClass> ownerList = new List<ProtoTestClass>
();
ProtoTestClass owner = new ProtoTestClass();
owner.Id = "799";
ownerList.Add(owner);
Dictionary<int, List<ProtoTestClass>> dictionaryList = new
Dictionary<int, List<ProtoTestClass>>();
dictionaryList.Add(1, ownerList);
using (Stream outfile = File.Open(@"d:\protobuftest.bin",
FileMode.OpenOrCreate))
{
ProtoBuf.Serializer.Serialize(outfile,
dictionaryList);
}
Dictionary<int, List<ProtoTestClass>> outDictionaryList =
new Dictionary<int, List<ProtoTestClass>>();
using (Stream inFile = File.Open(@"d:\protobuftest.bin",
FileMode.OpenOrCreate))
{
outDictionaryList =
ProtoBuf.Serializer.Deserialize<Dictionary<int, List<ProtoTestClass>>>
(inFile);
}
// now write just list again in the same file
using (Stream outfile = File.Open(@"d:\protobuftest.bin",
FileMode.OpenOrCreate))
{
ProtoBuf.Serializer.Serialize(outfile, ownerList);
}
List<ProtoTestClass> outList = new List<ProtoTestClass>();
using (Stream inFile = File.Open(@"d:\protobuftest.bin",
FileMode.OpenOrCreate))
{
outList =
ProtoBuf.Serializer.Deserialize<List<ProtoTestClass>>(inFile);
}
Console.WriteLine("Done with test");
}
> 2009/12/21 jeevankodali <jeevankod...@gmail.com>
> > <protobuf%2Bunsubscr...@googlegroups.com>
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
> 2009/12/22 jeevankodali <jeevankod...@gmail.com>
> -- ...
>
> read more »- Hide quoted text -
2009/12/22 jeevankodali <jeevan...@gmail.com>
> > <protobuf%2Bunsubscr...@googlegroups.com>> > > >> prot...@googlegroups.com<protobuf%2Bunsubscribe@googlegroups.com>
> > > >> .
> > > >> For more options, visit this group at
> > > >>http://groups.google.com/group/protobuf?hl=en.
>
> > > > --
> > > > Regards,
>
> > > > Marc
>
> > > --
> > > Regards,
>
> > > Marc- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Protocol Buffers" group.
> > To post to this group, send email to prot...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > prot...@googlegroups.com<protobuf%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/protobuf?hl=en.
>
> --
> Regards,
>
> Marc- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to prot...@googlegroups.com.
--
Regards,
Marc