2

我想将这个问题暴露给堆栈溢出社区,看看是否有人可以给我一些关于如何解决这个问题的意见。这里的主要目标是使用 Mono 的mkbundle工具来创建一个独立的二进制文件,该二进制文件将在没有安装单声道(或相关库)的嵌入式系统环境中执行。

项目代码示例

我正在使用的应用程序是一个简单加载窗口的小示例。在此图像上,您可以看到依赖项,我已将其设置为包含所有这些依赖项的本地副本。这意味着 . 这些引用的dll及其dll 映射配置都将与可执行文件一起出现在调试文件夹中。还应该注意的是,如果我不包含依赖项的本地副本,则mkbundle命令将失败。

所以我尝试用这个命令执行 mkbundle:

mkbundle -o App App..exe --simple --deps --machine-config "/usr/etc/etc/mono/4.5/machine.config" --config "/etc/mono/config"

之后,我收到了这份关于链接程序集和库的有希望的报告:

   Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/Graphics.exe
 Assembly: /usr/lib/mono/4.5/mscorlib.dll
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/gtk-sharp.dll
   Config: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/gtk-sharp.dll.config
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/glib-sharp.dll
   Config: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/glib-sharp.dll.config
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/System.dll
 Assembly: /usr/lib/mono/4.5/System.Configuration.dll
 Assembly: /usr/lib/mono/4.5/System.Xml.dll
 Assembly: /usr/lib/mono/4.5/System.Security.dll
 Assembly: /usr/lib/mono/4.5/System.Core.dll
 Assembly: /usr/lib/mono/4.5/System.Numerics.dll
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/gdk-sharp.dll
   Config: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/gdk-sharp.dll.config
 Assembly: /usr/lib/mono/4.5/Mono.Cairo.dll
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/pango-sharp.dll
   Config: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/pango-sharp.dll.config
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/atk-sharp.dll
   Config: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/atk-sharp.dll.config
 Assembly: /home/tansvanio/Projects/Graphics/Graphics/bin/Debug/Mono.Posix.dll
 Assembly: /usr/lib/mono/4.5/I18N.West.dll
 Assembly: /usr/lib/mono/4.5/I18N.dll

系统配置:/etc/mono/config 机器配置:/usr/etc/mono/4.5/machine.config

正如我们所看到的,不仅来自/etc/mono/config中原始单声道映射的 DLLS 链接,而且还有我们的 gtk 依赖项所需的DLLS。

在此之后,我将尝试运行生成的二进制文件。

./App

应用程序崩溃并给我这个错误:

Unhandled Exception:
System.TypeLoadException: Could not set up parent class, due to: Could not 
set up parent class, due to: Could not set up parent class, due to: Could 
not set up parent class, due to: Could not set up parent class, due to: 
Could not set up parent class, due to: Could not set up parent class, due 
to: Could not load type of field 'GLib.Object:before_handlers' (15) due to: 
Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089' or one of its dependencies. assembly:glib- 
sharp.dll type:Object member:(null) assembly:glib-sharp.dll 
type:InitiallyUnowned member:(null) assembly:gtk-sharp.dll type:Object 
member:(null) assembly:gtk-sharp.dll type:Widget member:(null) assembly:gtk- 
sharp.dll type:Container member:(null) assembly:gtk-sharp.dll type:Bin 
member:(null) assembly:gtk-sharp.dll type:Window member:(null)
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not set 
up 
parent class, due to: Could not set up parent class, due to: Could not set up parent class, due to: Could not set up parent class, due to: Could not set up parent class, due to: Could not set up parent class, due to: Could not set up parent class, due to: Could not load type of field 'GLib.Object:before_handlers' (15) due to: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. assembly:glib-sharp.dll type:Object member:(null) assembly:glib-sharp.dll type:InitiallyUnowned member:(null) assembly:gtk-sharp.dll type:Object member:(null) assembly:gtk-sharp.dll type:Widget member:(null) assembly:gtk-sharp.dll type:Container member:(null) assembly:gtk-sharp.dll type:Bin member:(null) assembly:gtk-sharp.dll type:Window member:(null)

这真的很令人沮丧,因为我已经多次尝试过这个过程,并确认它适用于没有参考的小型应用程序。我想知道是否有人以前遇到过这个问题并且知道如何解决这个问题,或者如果我以某种方式失败了。

最好的问候,里卡多

4

0 回答 0