我被要求在Ubuntu (14.04)上编写一个小型仪器校准应用程序,并一直在编写一些概念证明应用程序(串行i/o、GUI、SQLite等)。看看莫诺是否合适。在我测试我最喜欢的日志程序包log4net之前,一切都进行得很顺利。我不能让密码起作用。下面是一个简单的测试应用程序,它在Windows盒上运行得很好:
using System;
using log4net;
using log4net.Config;
public class L
{
public static void Main(string[] args)
{
Console.WriteLine("Version: " + Environment.Version);
XmlConfigurator.Configure(
new System.IO.FileInfo("console.logconfig.xml"));
Console.WriteLine("logging configured.");
ILog log = LogManager.GetLogger("root");
log.Info("This is an info message.");
log.Warn("This is a warning message.");
log.Error("This is an error message.");
}
}用
gmcs -pkg:log4net,dotnet -main:L -out:L.exe L.cs代码编译,但生成运行时错误:
Version: 2.0.50727.1433
Missing method System.Reflection.Assembly::op_Equality(Assembly,Assembly) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/log4net/1.2.10.0__a5715cc6d5c3540b/log4net.dll
Unhandled Exception:
System.MissingMethodException: Method not found: 'System.Reflection.Assembly.op_Equality'.
at log4net.LogManager.GetRepository (System.Reflection.Assembly repositoryAssembly) [0x00000] in <filename unknown>:0
at log4net.Config.XmlConfigurator.Configure (System.IO.FileInfo configFile) [0x00000] in <filename unknown>:0
at L.Main (System.String[] args) [0x00000] in <filename unknown>:0这看起来像是.Net版本错配(也许op_equality在.Net 2.0中是不可用的?)。当我试图强制使用SDK的版本4或4.5时:
gmcs -sdk:4.5 -pkg:log4n35,dotnet -main:L -out:L.exe L.cs我得到一个编译错误:
error CS0006: Metadata file `cscompmgd.dll' could not be found这是在一个全新的Ubuntu14.04VM上安装的,Mono通过:
sudo apt-get install mono-complete
sudo apt-get install liblog4net1.2-cil
sudo apt-get install liblog4net-cil-dev请给我推荐?
发布于 2015-02-14 05:40:41
不幸的是,为Ubuntu打包的log4net版本(1.2.10)非常陈旧,并且.NET 4.0存在问题。1.2.11已于2011年10月发布,截至本文撰写之时,1.2.13是最新的版本。
您需要直接从Apache log4net站点下载最新版本:log4net.cgi。
发布于 2018-04-23 23:38:21
你差点就有了;Ubuntu 14.04:
gmcs -sdk:4.5 -r:/usr/lib/cli/log4net-1.2/log4net.dll App.cs
https://stackoverflow.com/questions/28487781
复制相似问题