本文介绍了.NET Core 中的“System.Diagnostics"和 nix*es 上的 Mono 中不存在“Eventing"命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个 C# 应用程序,它可以使用以下导入读取和查询 Windows 事件日志:

I'm currently developing a C# application that can read and query Windows Event Logs using the following import:

using System.Diagnostics.Eventing.Reader;

此导入在使用 Visual Studio 2017 的 Windows 10 笔记本电脑上运行良好.但是,我在 dotnet run 上运行此导入并在 mcs 上编译时出现以下错误:

This import worked fine on my Windows 10 laptop using Visual Studio 2017. However, I got the following error running this import on dotnet run and compiling this on mcs:

Program.cs(3,26): error CS0234: The type or namespace name `Eventing' does not 
exist in the namespace `System.Diagnostics'. Are you missing an assembly 
reference? Compilation failed: 1 error(s), 0 warnings

我已经在 Mac OS X 笔记本电脑和 mono Docker 容器上尝试过编译.似乎它应该适用于 Mac 和 Linux,因为我在他们的 GitHub 存储库.有人有线索吗?我一直试图找到一个 dll 或一个导入来完成这项工作,但到目前为止没有成功.任何帮助将不胜感激.

I've tried the compilation on Mac OS X laptop and the mono Docker container. It seems like it should work on Mac and Linux since I found the code on their GitHub repository. Anyone have a clue? I have been trying to find a dll or an import to make this work, but no success so far. Any help would be appreciated.

推荐答案

.NET Framework 的那部分尚未移植到 .NET Core 2.0.目前正在实施中.请参阅:Port System.Diagnostics.EventLog 到 .NET Core,这是正在进行的工作的一部分将更多 System.Diagnostics 命名空间引入 .NET Core.EventLog 将在 v2.1.0 中发布.

That part of .NET Framework has not been ported into .NET Core 2.0. It is currently in implementation. See: Port System.Diagnostics.EventLog to .NET Core which is a part ongoing effort to bring more of System.Diagnostics namespace into .NET Core. EventLog will be shipped in v2.1.0.

我不知道 System.Diagnostics.Eventing.Reader 将在哪个特定版本中发货.

I do not know the specific version in which System.Diagnostics.Eventing.Reader will be shipped.

System.Diagnostics.EventLog 在 Linux 上被重定向到 syslog.也应该支持读取日志

System.Diagnostics.EventLog is redirected to syslog on Linux. Reading of logs should be supported as well

这篇关于.NET Core 中的“System.Diagnostics"和 nix*es 上的 Mono 中不存在“Eventing"命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 17:18