这是我遇到的问题:我使用 MonoDevelop 编写了一个 Gtk# 程序并且运行良好。但现在我希望能够在其他 Linux 机器上运行它而无需安装 MonoDevelop。
我的解决方案有两个项目:主 Gtk# 应用程序和它所依赖的 C# 库项目。因此,当我构建主项目时,它会生成 MainProject.exe 和 MainProject.exe.mdb,以及 bin/Release 文件夹中的 DependencyProject.dll。
我尝试运行以下命令将其全部打包到一个可执行文件中(从 bin/Release 文件夹运行):
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 问题,但没有一个提供任何实用的解决方案。如何有效地使用此 mkbundle
命令?
最佳答案
mkbundle
如果您想要一个完全独立的应用程序,它非常棒,它不依赖于安装在目标机器上的单声道或任何与单声道相关的东西。
但是,在 mono pages ,你可以读到: “生成的可执行文件是自包含的,不需要安装 Mono 运行时即可运行。但是,如果您的应用程序依赖于由 mono 运行时或 Gtk# 链接的库,则需要安装这些库(想到 Gtk# 帮助库)。”
如果您只想从几个 dll 创建一个可执行文件,那么 ILRepack是更好的选择。
如果您要部署到 Windows,那么您可以只包含 GTK# installer与您的应用程序(.NET 可能已经存在)。如果您要部署到 linux 或 mac,您需要在应用运行之前安装 mono 包(不一定是 mono-complete
)。
希望这对您有所帮助。
关于linux - 如何在 Linux 上捆绑 Mono/GTK# 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31632388/