Catalina MacOS上的mono运行时异常

Catalina MacOS上的mono运行时异常,mono,dylib,macos-catalina,Mono,Dylib,Macos Catalina,我有一个由.NET制作的应用程序,我使用mono 6.4.0.198(我使用最新的mono,因此该应用程序与Catalina MacOS兼容)在Mac电脑上运行它,在我的电脑上安装mono,因此该应用程序工作正常,但当我在其他Mac电脑上运行该应用程序时,它会返回以下异常 [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the

我有一个由
.NET
制作的应用程序,我使用
mono 6.4.0.198
(我使用最新的mono,因此该应用程序与Catalina MacOS兼容)在Mac电脑上运行它,在我的电脑上安装mono,因此该应用程序工作正常,但当我在其他Mac电脑上运行该应用程序时,它会返回以下异常

[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Diagnostics.SystemDiagnosticsSection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Diagnostics.AssertSection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ComponentModel.TypeDescriptor' threw an exception. ---> System.DllNotFoundException: /libmono-native-compat.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Interop+Sys.GetNonCryptographicallySecureRandomBytes(byte*,int)
  at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.Guid.NewGuid () [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.ComponentModel.TypeDescriptor..cctor () [0x00034] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
   --- End of inner exception stack trace ---
  at System.Configuration.ConfigurationProperty..ctor (System.String name, System.Type type, System.Object defaultValue, System.Configuration.ConfigurationPropertyOptions options) [0x00000] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Diagnostics.AssertSection..cctor () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at System.Diagnostics.SystemDiagnosticsSection..cctor () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <b814b509d4ad406fb40c6c93e38929e7>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00095] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) [0x00009] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) [0x00027] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic, System.Boolean wrapExceptions) [0x00020] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <b814b509d4ad406fb40c6c93e38929e7>:0 
  at System.Configuration.ConfigInfo.CreateInstance () [0x00026] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.SectionInfo.CreateInstance () [0x00000] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, System.Boolean createDefaultInstance) [0x0001c] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x0002c] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.Configuration.GetSection (System.String sectionName) [0x00016] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00006] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00005] in <181a8ffed1274b05b3ed7ea8bc6e1333>:0 
  at System.Configuration.PrivilegedConfigurationManager.GetSection (System.String sectionName) [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.DiagnosticsConfiguration.GetConfigSection () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.DiagnosticsConfiguration.Initialize () [0x0002a] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.DiagnosticsConfiguration.get_IndentSize () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.TraceInternal.InitializeSettings () [0x0004e] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.TraceInternal.get_Listeners () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at System.Diagnostics.Trace.get_Listeners () [0x00000] in <6aa0b19d109a447c94d1b43ec4471dc6>:0 
  at Zoolz.Program.Main (System.String[] args) [0x00040] in <d6a87962027b42c6878475ce75623731>:0 
[ERROR]致命的未处理异常:System.Reflection.TargetInvocationException:调用的目标已引发异常。-->System.TypeInitializationException:“System.Diagnostics.SystemDiagnosticsSection”的类型初始值设定项引发异常。-->System.TypeInitializationException:“System.Diagnostics.AssertSection”的类型初始值设定项引发异常。-->System.TypeInitializationException:“System.ComponentModel.TypeDescriptor”的类型初始值设定项引发异常。-->System.DllNotFoundException:/libmono-native-compat.dylib程序集:类型:成员:(null)
at(包装器管理为本机)Interop+Sys.GetNonCryptographicallySecureRandomBytes(字节*,int)
在Interop.GetRandomBytes处(System.Byte*缓冲区,System.Int32长度)[0x00000]输入:0
位于:0中的System.Guid.NewGuid()[0x00000]处
位于:0中的System.ComponentModel.TypeDescriptor..cctor()[0x00034]处
---内部异常堆栈跟踪的结束---
在System.Configuration.ConfigurationProperty..ctor(System.String名称、System.Type类型、System.Object默认值、System.Configuration.ConfigurationPropertyOptions选项)[0x00000]中:0
位于:0中的System.Diagnostics.AssertSection..cctor()[0x00000]处
---内部异常堆栈跟踪的结束---
at(wrapper managed to native)System.Object.\uuIcall\uwrapper\uMono\uGeneric\uClass\uInit(intptr)
在System.Diagnostics.SystemDiagnosticsSection..cctor()[0x00000]中:0
---内部异常堆栈跟踪的结束---
在(包装器管理为本机)System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
在:0中的System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Object obj,System.Object[]参数,System.Boolean WrapeExceptions)[0x00005]处
---内部异常堆栈跟踪的结束---
在System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Object obj,System.Object[]参数,System.Boolean WrapeExceptions)[0x0001a]中:0
在:0中的System.RuntimeType.CreateInstanceMono(System.Boolean非公共,System.Boolean WrapeExceptions)[0x00095]处
在System.RuntimeType.CreateInstanceSlow(System.Boolean publicOnly,System.Boolean WrapeExceptions,System.Boolean skipCheckThis,System.Boolean fillCache)[0x00009]中:0
在System.RuntimeType.CreateInstanceDefaultCtor(System.Boolean publicOnly,System.Boolean skipCheckThis,System.Boolean fillCache,System.Boolean WrapeExceptions,System.Threading.StackScrawlMark&stackMark)[0x00027]中:0
在System.Activator.CreateInstance(System.Type类型,System.Boolean非公共,System.Boolean WrapeExceptions)[0x00020]中:0
在:0中的System.Activator.CreateInstance(System.Type类型,System.Boolean非公共)[0x00000]处
位于:0中的System.Configuration.ConfigInfo.CreateInstance()[0x00026]处
位于:0中的System.Configuration.SectionInfo.CreateInstance()[0x00000]处
在:0中的System.Configuration.Configuration.GetSectionInstance(System.Configuration.SectionInfo配置,System.Boolean createDefaultInstance)[0x0001c]处
在0中的System.Configuration.ConfigurationSectionCollection.get_项(System.String名称)[0x0002c]处
在:0中的System.Configuration.Configuration.GetSection(System.String sectionName)[0x00016]处
在0中的System.Configuration.ClientConfigurationSystem.System.Configuration.InternalConfigSystem.GetSection(System.String configKey)[0x00006]处
在0中的System.Configuration.ConfigurationManager.GetSection(System.String sectionName)[0x00005]处
在:0中的System.Configuration.PrivilegedConfiguration Manager.GetSection(System.String sectionName)[0x00000]处
位于:0中的System.Diagnostics.DiagnosticsConfiguration.GetConfigSection()[0x00000]处
在System.Diagnostics.DiagnosticsConfiguration.Initialize()[0x0002a]中:0
在System.Diagnostics.DiagnosticsConfiguration.get_IndentSize()[0x00000]中:0
在System.Diagnostics.TraceInternal.InitializeSettings()[0x0004e]中:0
在:0中的System.Diagnostics.TraceInternal.get_侦听器()[0x00000]处
在System.Diagnostics.Trace.get_侦听器()[0x00000]中:0
在Zoolz.Program.Main(System.String[]args)[0x00040]处输入:0

很明显,这是一个缺失的dll
libmono native compat.dylib
i在应用程序资源中与其他dll一起添加了此dll,但应用程序仍返回相同的缺失dll异常,如何将mono定向到dll以便解决此问题

在安装macOS Catalina时,我遇到了许多错误,直到我决定授予/private/tmp文件夹的权限。现在似乎所有的应用程序都可以工作了。我不知道这是否是你的情况,但以防万一,试试这个:

sudo chmod 777 /private/tmp

我用计算机解决了这个问题

创建一个名为
fix.config
的文件,其中包含以下XML

<configuration>
    <dllmap dll="System.Native" target="libmono-native-compat.dylib" os="!windows" />
    <dllmap dll="System.Net.Security.Native" target="libmono-native-compat.dylib" os="!windows" />
    <dllmap dll="System.Security.Cryptography.Native.Apple" target="libmono-native-compat.dylib" os="osx" />
</configuration>

我将XML中提到的三个动态库复制到路径
Application/MyApp.app/Contents/lib

然后在构建脚本中,我向工具
mkbundle
添加了以下命令

--config$SETUP\u DIR/fix.config
和SETUP path是我创建
.pkg
文件的路径


注意:我使用的是mono版本
6.4.0.198

不,实际上我的案例是一个缺少的动态库,谢谢,不管怎样,到目前为止运气好吗?我尝试过不同版本的mono(6.0.0到当前可用的6.8.0),但它们最终都在libmono-native-compat.dylib上出现相同的DLLNotFoundException。将动态库复制到可执行文件的结束位置也不起作用,而mkbundle将其复制到可执行文件中也不起作用,因为出现了一些错误的图像格式异常