Dr. Strangelove
Dr. Strangelove

Reputation: 3328

protobuf-net + Mono + Linux

I'm using protobuf-net for serializing my data. Everything works fine under Windows, I use Mono to run the sample project under Linux but seems it is not straightforward.

I receive following error:

Missing method Skip in assembly /home/***/Debug/Di3.dll, type System.Linq.Enumerable Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.

The exception is thrown at following line:

var instance = new ToSerializeClass();

And the class is defined as:

[ProtoContract]
public class ToSerializeClass
{
    internal ToSerializeClass()
    {// it seems that the protobuf net needs this constructor. 
    }

    [ProtoMember(1)]
    internal int omega { set; get; }

    [ProtoMember(2)]
    internal List<Lambda> lambda { set; get; }
}

I copy the debug/deploy folder to linux, replace the protobuf-net.dll and protobuf-net.xml with the ones published for Mono and call my program using Mono.

Am I missing any points here?

Upvotes: 2

Views: 1579

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1063338

It sounds like the main problem here is your project setup and build process. Visual Studio, out if the box, does not target mono. If you stick to down-level .net versions (2.0, 3.0, etc) it will usually just work, but this gets flakier with higher versions.

The more typical thing to do here is to use a different project/build for targeting mono. This could be MonoDevelop, Xamarin, or mcs at the command-line. With these tools, you should be able to correctly compile your project targeting mono and the available framework versions.

In particular, note that protobuf-net does not use LINQ at all, and does not reference System.Core - so that load exception has nothing whatsoever to do with protobuf-net. Most likely, the mono runtime simply doesn't recognise the core references you have configured for your test project.

Upvotes: 1

Related Questions