我的解决方案有两个项目:主要的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.String codebase) [0x00000] in :0
我看到了其他一些类似问题的Stack Overflow问题,但没有一个提供任何实用的解决方案.如何有效地使用此mkbundle命令?
解决方法
但是,在mono pages中,您可以读到:
“生成的可执行文件是自包含的,不需要安装Mono运行时来运行.但是,如果您的应用程序依赖于由单声道运行时或Gtk#链接的库,则需要安装这些库(Gtk #helper库让我想到) )“.
如果您只想从几个dll创建一个可执行文件,那么ILRepack是更好的选择.
如果要部署到Windows,则只需将GTK# installer包含在您的应用程序中(.NET可能已经存在).如果要部署到linux或mac,则需要在应用程序运行之前安装单声道程序包(不一定是单声道完成).
希望这可以帮助.