Question

I'm writing a Window's Service and referencing the protobuf-net.dll in CoreOnly/net30. I'm using the following code:

                MyJob job;
                using (var file = File.OpenRead("myjob.bin"))
                {
                    job = Serializer.Deserialize<MyJob>(file);
                }

The error I'm getting is: 'ProtoBuf.Serializer' does not contain a definition for 'Deserialize'

What am I missing?

Was it helpful?

Solution

Use "Full".

If you are using CoreOnly, then you are using the Google code download. In the root of the zip is a file called "what files do I need.txt" (or something similar), which explains what CoreOnly is, and how to use it. The short version is that it doesn't include the meta-programming layer, and is intended to be used with the precompile tool. The methods directly on Serializer are tied to the default, meta-programming-based model - hence are not available in CoreOnly.

The main use of CoreOnly is for environments like mobile devices where meta-programming is not possible. Actually, it is usually easier to use the NuGet download, which only includes the Full version.

I am, however, tempted to add these methods, but with an [Obsolete("some text", true)] that explains all this - to avoid future confusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top