I cannot reproduce it erroring; your code, copied directly, works fine:
static void Main()
{
var data = new Message("abc").Serialize();
}
But, to try to help:
first,
catch
theException
, and look at the.InnerException
. More information is available for most exceptions; for example:try { // HERE: the code that errors } catch(Exception ex) { while(ex != null) { Console.Error.WriteLine(ex.Message); ex = ex.InnerException; } throw; }
secondly, note that a common issue with inheritance models is not declaring the inheritance - look at whether perhaps the base class needs decorating, for example:
[ProtoInclude(1, typeof(Message))]
another observation is the lack of a public parameterless constructor; now, protobuf-net doesn't insist on that (and indeed, it looks like it is treating the code in the question as an "auto tuple", and using the constructor that exists), but you can also either provide an additional (possibly non-public) parameterless constructor:
private Message() {}
or tell it to skip the constructor completely:
[ProtoContract(SkipConstructor = true)]
But: without knowing what the exception message is, it is hard to speculate further than this.