gpt4 book ai didi

c# - protobuf-net + Mono + Linux

转载 作者:太空宇宙 更新时间:2023-11-03 13:15:42 25 4
gpt4 key购买 nike

我正在使用 protobuf-net 序列化我的数据。在 Windows 下一切正常,我使用 Mono 在 Linux 下运行示例项目,但似乎并不简单。

我收到以下错误:

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.

异常在以下行抛出:

var instance = new ToSerializeClass();

类定义为:

[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; }
}

我将 debug/deploy 文件夹复制到 linux,将 protobuf-net.dllprotobuf-net.xml 替换为为 Mono< 发布的那些 并使用 Mono 调用我的程序。

我是否遗漏了任何要点?

最佳答案

听起来这里的主要问题是您的项目设置和构建过程。 Visual Studio,开箱即用,不针对单声道。如果您坚持使用较低级别的 .net 版本(2.0、3.0 等),它通常就可以正常工作,但是对于更高版本,这会变得不稳定。

这里更典型的做法是使用不同的项目/构建来定位单声道。这可以是命令行中的 MonoDevelop、Xamarin 或 mcs。使用这些工具,您应该能够正确编译针对单声道和可用框架版本的项目。

请特别注意,protobuf-net 根本不使用 LINQ,并且不引用 System.Core - 因此加载异常与 protobuf-net 没有任何关系。最有可能的是,mono 运行时根本无法识别您为测试项目配置的核心引用。

关于c# - protobuf-net + Mono + Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26325573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com