我无法部署我的单声道应用程序,因为o DllNotFoundException

时间:2012-10-20 11:32:28

标签: c# mono

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

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上搜索丢失的glibsharpglue-2库但找不到它。我不确定问题是什么,因为应用程序在我从Monodevelop启动时运行。

2 个答案:

答案 0 :(得分: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 "$@"

您所要做的就是确保脚本与可执行文件位于同一目录中以执行它。它允许您将选项传递给mono(例如--debug)。这通常是单声道的方式(例如cat /usr/bin/mkbundle),它位于offical Application Deployment Guidelines

答案 1 :(得分:0)

来自有类似问题的博客条目: http://ngeor.net/blog/post/2012/08/25/Mac-and-Mono.aspx 修改:更新后的链接:http://ngeor.net/2012/08/mac-and-mono/

这里的问题是缺少环境变量。我修改了这样的/ 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"