0

当我尝试使用以下命令运行我的单声道应用程序时:

mono SimpleBrowser.exe

我在我的 Mac 上收到以下错误:

Unhandled Exception: System.TypeInitializationException: An exception  was thrown by the type initializer for Gtk.Application ---> System.DllNotFoundException: glibsharpglue-2
  at (wrapper managed-to-native) GLib.Thread:glibsharp_g_thread_supported ()
  at GLib.Thread.get_Supported () [0x00000] in <filename unknown>:0
  at Gtk.Application..cctor () [0x00000] in <filename unknown>:0    
  --- End of inner exception stack trace ---
  at SimpleBrowser.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0  [ERROR]
  FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Gtk.Application ---> System.DllNotFoundException: glibsharpglue-2
  at (wrapper managed-to-native) GLib.Thread:glibsharp_g_thread_supported ()
  at GLib.Thread.get_Supported () [0x00000] in <filename unknown>:0
  at Gtk.Application..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at SimpleBrowser.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0

我尝试在我的 Mac 上搜索丢失的 glibsharpglie-2 库,但找不到。我不确定问题是什么,因为应用程序在我从 Monodevelop 启动时运行。

4

2 回答 2

5

您需要在执行应用程序之前设置此环境变量:

export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/usr/local/lib:/usr/lib"

由于每次执行应用程序时都很难做到这一点,因此您应该创建一个为您执行此操作的包装脚本:

#!/bin/bash 
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib:/usr/local/lib:/usr/lib"
mono SimpleBrowser.exe "$@"

这只是一个最小的示例,这里有一些更高级的:

#!/bin/bash 
MONO_FRAMEWORK=/Library/Frameworks/Mono.framework/Versions/Current/
export DYLD_FALLBACK_LIBRARY_PATH="$MONO_FRAMEWORK/lib:/usr/local/lib:/usr/lib"
EXE_DIR=`dirname $0`
$MONO_FRAMEWORK/mono $MONO_OPTIONS $EXE_DIR/SimpleBrowser.exe "$@"

您所要做的就是确保脚本与可执行文件位于同一目录中以执行它。它允许您将选项传递给单声道(例如 --debug )。这通常是 mono 的做法(cat /usr/bin/mkbundle例如),它在官方应用程序部署指南中。

于 2012-10-22T09:37:04.693 回答
0

来自具有类似问题的博客条目:http: //ngeor.net/blog/post/2012/08/25/Mac-and-Mono.aspx编辑:更新链接: http: //ngeor.net/2012/08 /mac和单声道/

这里的问题是缺少环境变量。我像这样修改了/etc/profile(第二行和第三行应该在同一行没有点,我只是把它分解以适应页面):

export MONO_FRAMEWORK_PATH=/Library/Frameworks/Mono.framework/Versions/Current export DYLD_FALLBACK_LIBRARY_PATH="$MONO_FRAMEWORK_PATH/lib:... ...$DYLD_FALLBACK_LIBRARY_PATH:/usr/local/lib:/lib:/usr/lib"

于 2012-10-20T11:44:07.240 回答