我想向堆栈溢出社区公开此问题,以查看是否有人可以给我一些有关如何解决此问题的意见。这里的主要目的是使用Mono的 mkbundle 工具来创建一个自包含的二进制文件,该二进制文件将在没有安装Mono(或相关库)的嵌入式系统环境中执行。
我正在使用的应用程序是一个仅加载窗口的小示例。在此图像上,您可以看到依赖项,我已对其进行设置以包括所有这些项的本地副本。这意味着这些引用的.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
systemconfig:/ etc / mono / config machineconfig:/usr/etc/mono/4.5/machine.config
我们看到,不仅链接了 / etc / mono / config 中原始Mono映射的DLLS,而且还有gtk依赖项所需的DLL。
此后,我将尝试运行生成的二进制文件。
./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)
这真令人沮丧,因为我已经尝试了几次此过程,并确认它适用于没有参考的小型应用程序。我想知道是否有人以前曾遇到过此问题,并且知道如何解决此问题,或者如果我因某种原因失败了,该怎么做。
最好的问候, 里卡多