VisualStudio2010中的GTK#我一直在尝试让GTK#在WindowsServer2008R2x64上的VisualStudio2010中工作,这样我就可以开始编写漂亮的跨平台程序GUI应用程序,但我对C#有点陌生,我在安装最新的WindowsMono(包括GTK#)时遇到了很多麻烦。我还安装了一个Mono2.10.8配置文件作为我项目的目标框架,大致遵循此处的指南:http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/I创建了一个新的Windows窗体应用程序并删除了对表单内容的引用并添加了对GTK#stuff的引用,大致遵循此处的指南:http://jrwren.wrenfam.com/blog/2008/11/01/gtk-X64-on-Vista-on-visual-studio-2008-/除了指南中的内容外,我还添加了对gtk-dotnet的引用。这是我的应用程序的完整代码:usingSystem;使用System.Runtime.InteropServices;使用System.Collections.Generic;使用System.Linq;使用Gtk;namespaceGridToGo{staticclassProgram{[STAThread]staticvoidMain(){Application.Init();WindowmyWin=newWindow("我的第一个GTK#应用程序!");myWin.Resize(200,200);myWin.Destroyed+=newEventHandler(myWin_Destroyed);标签myLabel=newLabel();myLabel.Text="你好世界!!!!";myWin.Add(我的标签);我的Win.ShowAll();应用程序运行();}staticvoidmyWin_Destroyed(objectsender,EventArgse){Application.Quit();当我尝试使用任何配置运行它时,我得到以下异常:System.TypeInitializationException未处理Message=Thetypeinitializerfor'Gtk.Application'throwanexception。Source=gtk-sharpTypeName=Gtk.ApplicationStackTrace:在Gtk.Application.Init()在GridToGo.Program.Main()在F:visual-studioGridToGoGridToGoProgram.cs:line13atSystem.AppDomain._nExecuteAssembly(RuntimeAssemblyassembly,String[]参数s)在System.AppDomain.ExecuteAssembly(StringassemblyFile,EvidenceassemblySecurity,String[]args)在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()在System.Threading.ThreadHelper.ThreadStart_Context(Objectstate)在System.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallbackcallback,Objectstate,BooleanignoreSyncCtx)atSystem.Threading.ExecutionContext.Run(ExecutionContextexecutionContext,ContextCallbackcallback,Objectstate)atSystem.Threading.ThreadHelper.ThreadStart()InnerException=System.DllNot无法加载DLL'glibsharpglue-2':找不到指定的模块。(HRESULT异常:0x8007007E)Source=glib-sharpTypeName=""StackTrace:在GLib.Thread.glibsharp_g_thread_supported()在GLib.Thread.get_Supported()在Gtk.Application..cctor()InnerException:我想不通找出如何找到那个DLL!我什至尝试将4个DLL副本复制到解决方案中的几乎每个文件夹中,名称如下:glibsharpglue-2glibsharpglue-2。dllglibsharpglue-2.oglibsharpglue-2.o.dll!我什至尝试从GTK站点安装GTK一体式软件包并将其bin文件夹添加到我的系统路径,然后将相同的4个dll复制到该文件夹??中,所有这些都没有让我发疯问题有什么建议吗?我觉得我在这里错过了一些大事。>_<我想通了!Windows的Mono是完全没有必要的。.NET的GTK#就是我所需要的。对于以后想要搭建Windows环境进行跨平台GTK#开发的朋友,以下是我遵循的步骤:以上就是C#学习教程:GTK#inVisualStudio2010的全部内容分享,如果有的话对大家有用,需要详细了解C#学习教程,希望大家关注——安装Mono项目target,里面包含以下说明:http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/来自官方Mono下载站点的InstallGTK#for.NET。安装适用于Windows的Glade/GTK+,sourceforge项目:http://sourceforge.net/projects/gladewin32/创建一个针对Mono的新C#项目。从安装GTK#for.NET的地方引用项目所需的程序集。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
