【发布时间】:2019-07-12 14:59:46
【问题描述】:
我正在使用 Microsoft Enterprise Library 6.0.1304 尝试新的 VisualStudio for Mac (Mono 6.0.0.296)。不幸的是,我无法使用它,因为引发了“NotImplementedException”。
我多年来一直在使用企业库,但在 Visual Studio (Windows Env.) 中,它很棒,但是当我尝试在单声道下使用相同的库时,一切似乎都无法正常工作。
经过一番搜索,我可以看到 MONO 的 mscorlib.dll 不支持 WindowsIdentity“用户”属性。
mscorlib.dll (4.0.0.0 - MONO)
using System.Runtime.InteropServices;
[MonoTODO ("not implemented")]
[ComVisible (false)]
public SecurityIdentifier User {
get {
throw new NotImplementedException ();
}
}
应用:
public static void Main (string [] args)
{
LogWriter logWriter = new LogWriterFactory ().Create ();
Logger.SetLogWriter (logWriter, false);
logWriter.Write ("Application is working", "General", 5, 2000, TraceEventType.Information);
}
App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name=""
tracingEnabled="false"
defaultCategory="General"
logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add name="Rolling Flat File Trace Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="RollingFlatFile.log"
footer="----------------------------------"
formatter="Text Formatter"
header="" rollInterval="Day"
traceOutputOptions="DateTime, Timestamp"
filter="All" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp(local)}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
Severity: {severity}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" autoFlush="true" name="General">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
</configuration>
跟踪到文件中的错误:
时间戳:12/07/2019 16:36:11
消息:消息处理失败。有关详细信息,请参阅下面的摘要信息。如果此问题仍然存在,请停止服务并检查配置文件以了解类别和接收器配置中可能存在的错误。
企业图书馆分发服务总结:
--> 信息: 时间戳:12/07/2019 14:36:11 消息:应用程序正在运行 类别:一般 优先级:5 事件编号:2000 严重性:信息 标题: 机器:MacBook-Pro-di-John 应用程序域:F.B.Library.exe ProcessId:无法读取内在属性。错误消息:GetCurrentProcessId 进程名称:无法读取内在属性。错误消息:GetModuleHandle 线程名称: Win32 ThreadId:无法读取内在属性。错误消息:GetCurrentThreadId 扩展属性: --> 机器名称:MacBook-Pro-di-John --> 时间戳:12/07/2019 14:36:11 --> 全名:Microsoft.Practices.EnterpriseLibrary.Logging,版本=6.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35 --> AppDomainName: F.B.Library.exe --> WindowsIdentity: jfk
异常信息详情:
异常类型:System.NotImplementedException 消息:方法或操作未实现。 数据:System.Collections.ListDictionaryInternal TargetSite:System.Security.Principal.WindowsIdentity GetCurrent(布尔值) 帮助链接:NULL 来源:mscorlib H结果:-2147467263
StackTrace 信息详情:
在 System.Security.Principal.WindowsIdentity.GetCurrent (System.Boolean ifImpersonating) [0x00000] 在 /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/ mono-x64/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs:165 在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.RevertExistingImpersonation () [0x0000f] 中:0 在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter.ProcessLog(Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry 日志,System.Diagnostics.TraceEventCache traceEventCache)[0x00000] 在:0
在 Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter+c__DisplayClass13.b__12 () [0x0007f] in :0
从日志中可以清楚地看到 System.Security.Principal.WindowsIdentity.GetCurrent 违反了规则...
您能帮我解决这个问题吗? 有没有人尝试在 MacOS 上将 Enterprise Library 与 Mono 一起使用? 有什么地方可以解决吗?
非常感谢您的帮助和时间。 问候,
【问题讨论】:
-
该库已有 6 年以上的历史,Microsoft 不再支持/维护,如果您想克隆它并为您的项目修改它,源代码可在 github 上的存档存储库中获得。 .
-
所以您知道它是
WindowsIdentity,而 EF 6 仅适用于 Windows。 Mono 不会帮助您神奇地填补非 Windows 平台上的任何空白。 -
@SushiHangover:是的,我知道那已经 6 岁以上了...问题不在 MEL 库上,而是在为单声道开发的 mscorlib.dll 上...目前是微软的新产品,应该被维护......
-
@Lex Li:是的,你说的没错,但我认为这可以解决这个问题以保持以前的兼容性......可能他们甚至不知道......或者可能有不同的方法来用于避免此类问题...这就是我的问题的目的...找到解决方案(如果有)或有效的替代方案(如果存在)!
-
github.com/Chavoshi/EnterpriseLibrary.NetCore + .NET Core 可能是您唯一的选择。
标签: c# .net logging mono enterprise-library