How can I bundle a Mono / GTK# application on Linux?
这是我遇到的问题:我使用MonoDevelop编写了一个Gtk#程序,它运行得很好。 但是现在,我希望能够在其他Linux机器上运行它,而不必安装MonoDevelop。
我的解决方案有两个项目:主Gtk#应用程序和它依赖的C#库项目。 因此,当我构建主项目时,它将在bin / Release文件夹中生成MainProject.exe和MainProject.exe.mdb,以及DependencyProject.dll。
我尝试运行以下命令将其打包为一个可执行文件(从bin / Release文件夹运行):
1 | mkbundle MainProject.exe -o mainproject --deps *.dll |
但是,我从运行该命令得到此错误:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'gtk-sharp' or one of its dependencies. The system cannot find the file specified.
File name: 'gtk-sharp'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string,System.Security.Policy.Evidence,bool)
at System.Reflection.Assembly.ReflectionOnlyLoad (System.String assemblyString) [0x00000] in :0
at IKVM.Reflection.Universe.DefaultResolver (System.String refname, Boolean throwOnError) [0x00000] in :0
at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, Boolean throwOnError) [0x00000] in :0
at IKVM.Reflection.Universe.Load (System.String refname) [0x00000] in :0
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1 files, System.String codebase) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'gtk-sharp' or one of its dependencies. The system cannot find the file specified.
File name: 'gtk-sharp'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string,System.Security.Policy.Evidence,bool)
at System.Reflection.Assembly.ReflectionOnlyLoad (System.String assemblyString) [0x00000] in :0
at IKVM.Reflection.Universe.DefaultResolver (System.String refname, Boolean throwOnError) [0x00000] in :0
at IKVM.Reflection.Universe.Load (System.String refname, IKVM.Reflection.Module requestingModule, Boolean throwOnError) [0x00000] in :0
at IKVM.Reflection.Universe.Load (System.String refname) [0x00000] in :0
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1 files, System.String codebase) [0x00000] in :0
我看到了其他一些具有类似问题的Stack Overflow问题,但是没有一个提供任何实际的解决方案。 如何有效使用此
如果您想要一个完全独立的应用程序,而该应用程序不依赖于Mono或与Mono相关的任何内容,那么
但是,在单声道页面中,您可以阅读以下内容:
"生成的可执行文件是自包含的,不需要安装Mono运行时即可运行。但是,如果您的应用程序依赖于Mono运行时或Gtk#链接的库,则需要安装这些库(请记住Gtk#帮助程序库 )。"
如果只想从几个dll创建单个可执行文件,则ILRepack是一个更好的选择。
如果要部署到Windows,则可以在应用程序中包括GTK#安装程序(.NET可能已经存在)。 如果要部署到linux或mac,则需要在应用运行之前安装单声道软件包(不一定是
希望这可以帮助。