mono 运行 Catalina MacOS 上的时间异常

mono Run Time Exception on Catalina MacOS

我有一个由 .NET 制作的应用程序,我使用 mono 6.4.0.198(我使用最新的单声道,因此该应用程序与 Catalina MacOS) 到 运行 它在 Mac 机器上,在我的机器上安装了单声道所以应用程序工作正常,但是当我 运行 应用程序在other Mac是return以下异常

[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 

很明显它缺少一个 dll libmono-native-compat.dylib 我在应用程序资源中添加了这个 dll 和其他 dll 但应用程序仍然 returning 相同的丢失 dll 异常,我如何将单声道定向到 dll 所以我会解决这个问题

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

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 中提到的三个 dylib 复制到路径 Application/MyApp.app/Contents/lib

然后在构建脚本中我将以下命令添加到工具mkbundle

--config $SETUP_DIR/fix.config 和设置路径是我创建 .pkg 文件的路径

注意:我使用的是单声道版本 6.4.0.198