简体   繁体   English

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

[英]I can't deploy my mono application because o DllNotFoundException

When I try to run my mono application using the following command: 当我尝试使用以下命令运行单声道应用程序时:

mono SimpleBrowser.exe

I get the following error on my Mac: 我在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

I've tried searching for the missing glibsharpglue-2 library on my Mac but couldn't find it. 我尝试在Mac上搜索缺少的glibsharpglue-2库,但找不到它。 I'm not sure what the problem is because the application runs when I launch it from Monodevelop. 我不确定是什么问题,因为当我从Monodevelop启动它时,该应用程序会运行。

You need to set this environment variable before executing your app: 您需要在执行应用之前设置此环境变量:

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

Since this is a pain to do every time you execute your app, you should create a wrapper script that does it for you: 由于每次执行应用程序都会很麻烦,因此您应该创建一个为您执行此操作的包装器脚本:

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

This is just a minimal sample, here is a bit more advanced: 这只是一个最小的示例,这里有些高级:

#!/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 "$@"

And all you have to do is make sure the script is in the same directory as the executable to execute it. 您要做的就是确保脚本与可执行文件位于同一目录中。 It allows allows you to pass options to mono (such as --debug for instance). 它允许您将选项传递给mono(例如--debug)。 This is usually how mono does it ( cat /usr/bin/mkbundle for an example), and it's in the offical Application Deployment Guidelines . 通常,这是mono的工作方式(例如cat /usr/bin/mkbundle ),这在正式的Application Deployment Guidelines中

From a blog entry with a similar problem: http://ngeor.net/blog/post/2012/08/25/Mac-and-Mono.aspx Edit: updated link: http://ngeor.net/2012/08/mac-and-mono/ 来自具有类似问题的博客条目: http : //ngeor.net/blog/post/2012/08/25/Mac-and-Mono.aspx 编辑:更新的链接: http : //ngeor.net/2012/08 / MAC和-单声道/

The problem here was with missing environment variables. 这里的问题是缺少环境变量。 I modified /etc/profile like this (the second and third line are supposed to be on the same line without the dots, I only broke it down to fit the page): 我这样修改了/ 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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM