Visual Studio 2010中的GTK#

我一直在努力让GTK#​​在Windows Server 2008 R2 x64上的Visual Studio 2010中工作,这样我就可以开始编写漂亮的跨平台GUI应用程序,但我对C#有些新意,我有一个世界麻烦

我安装了最新的Mono for Windows,其中包括GTK#。 我还安装了一个Mono 2.10.8配置文件作为我的项目的目标框架,松散地遵循这里的指南: http : //erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/

我创建了一个新的Windows窗体应用程序并删除了对窗体表单内容的引用,并为GTK#stuff添加了引用,松散地遵循这里的指南: http : //jrwren.wrenfam.com/blog/2008/11/01/gtk-在视觉工作室-2008-上Vista的X64 /

除了指南中的那些之外,我还添加了对gtk-dotnet的引用。

这是我的应用程序的完整代码:

using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Linq; using Gtk; namespace GridToGo { static class Program { [STAThread] static void Main() { Application.Init(); Window myWin = new Window("My first GTK# Application! "); myWin.Resize(200, 200); myWin.Destroyed += new EventHandler(myWin_Destroyed); Label myLabel = new Label(); myLabel.Text = "Hello World!!!!"; myWin.Add(myLabel); myWin.ShowAll(); Application.Run(); } static void myWin_Destroyed(object sender, EventArgs e) { Application.Quit(); } } } 

当我尝试使用任何配置运行它时,我得到以下exception:

 System.TypeInitializationException was unhandled Message=The type initializer for 'Gtk.Application' threw an exception. Source=gtk-sharp TypeName=Gtk.Application StackTrace: at Gtk.Application.Init() at GridToGo.Program.Main() in F:\visual-studio\GridToGo\GridToGo\Program.cs:line 13 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.DllNotFoundException Message=Unable to load DLL 'glibsharpglue-2': The specified module could not be found. (Exception from HRESULT: 0x8007007E) Source=glib-sharp TypeName="" StackTrace: at GLib.Thread.glibsharp_g_thread_supported() at GLib.Thread.get_Supported() at Gtk.Application..cctor() InnerException: 

我无法弄清楚如何让它找到那个DLL! 我甚至尝试将4个DLL副本复制到解决方案中的几乎每个文件夹中,名称如下: glibsharpglue-2 glibsharpglue-2.dll glibsharpglue-2.o glibsharpglue-2.o.dll ! 我甚至尝试从GTK站点安装GTK一体化软件包并将其bin文件夹添加到我的系统路径,然后将相同的4个dll复制到该文件夹​​中,所有这些都没有运气。

对我疯狂的问题有什么建议吗? 我觉得我在这里错过了一些大事。 > _ <

我想到了! Mono for Windows完全没必要。 GTK#for .NET是我所需要的。 对于未来想要为跨平台GTK#开发设置Windows环境的任何人,以下是我遵循的步骤:

  1. 安装Mono项目目标,其中包含以下说明: http : //erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/
  2. 从官方Mono下载站点安装GTK#for .NET。
  3. 安装Glade / GTK + for Windows,sourceforge项目: http : //sourceforge.net/projects/gladewin32/
  4. 创建一个面向Mono的新C#项目。
  5. 从安装GTK#for .NET的位置引用项目所需的程序集。