GTK#在Visual Studio 2010中 [英] GTK# in Visual Studio 2010

查看:250
本文介绍了GTK#在Visual Studio 2010中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一整天都在尝试让GTK#​​在Windows Server 2008 R2 x64上的Visual Studio 2010中工作,以便我可以开始编写出色的跨平台GUI应用程序,但是我对C#有些新颖,而且我遇到了麻烦。

I've been trying all day to get GTK# working in Visual Studio 2010 on Windows Server 2008 R2 x64 so that I can start writing nice cross-platform GUI applications, but I'm somewhat new to C# and I'm having a world of trouble.

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

I installed the latest Mono for Windows which includes GTK#. I also installed a Mono 2.10.8 profile to be the target framework of my project loosely following the guide from here: http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/

我创建了一个新的Windows窗体应用程序,并删除了对Windows窗体内容的引用,并为GTK#内容添加引用,松散地遵循以下指导: http://jrwren.wrenfam.com/blog/2008/11/01 / gtk-in-visual-studio-2008-on-vista-x64 /

I created a new Windows Forms application and removed references to the windows forms stuff and adding references for GTK# stuff, loosely following the guide from here: http://jrwren.wrenfam.com/blog/2008/11/01/gtk-in-visual-studio-2008-on-vista-x64/

除了那些我还添加了对gtk-dotnet的引用

I also added a reference to gtk-dotnet in addition to the ones from that guide.

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

This is my application's complete code:

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();
        }
    }
}

当我尝试运行这个在任何配置下,我得到以下异常:

When I try to run this with any configuration, I get the following 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 all-in-one软件包,并将其bin文件夹添加到我的系统路径中,然后将相同的4个dll复制到该文件夹​​中,所有这些都没有运气。

I can't figure out how to get it to find that dll! I even tried copying 4 copies of the DLL into pretty much every folder in the solution with the following names: glibsharpglue-2 glibsharpglue-2.dll glibsharpglue-2.o glibsharpglue-2.o.dll! I also even tried installing the GTK all-in-one package from the GTK site and adding its bin folder to my system path, and then copying the same 4 dlls into that folder, all with no luck.

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

Any advice for my crazy problem? I feel like I'm missing something big here. >_<

推荐答案

我想通了!单声道的Windows是完全没有必要的。 GTK#for .NET是我所需要的。对于将来希望为跨平台GTK#开发设置Windows环境的人,请遵循以下步骤:

I figured it out! Mono for Windows was completely unnecessary. GTK# for .NET is what I needed. For anyone in the future wanting to set up their Windows environment for cross platform GTK# development, here are the steps I followed:


  1. 安装单声道项目的目标与从这里的方向: 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。

  1. Install a Mono project target with directions from here: http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/
  2. Install GTK# for .NET from the official Mono download site.
  3. Install Glade/GTK+ for Windows, sourceforge project here: http://sourceforge.net/projects/gladewin32/
  4. Create a new C# project targeting Mono.
  5. Reference the necessary assemblies for your project from where you installed GTK# for .NET.

这篇关于GTK#在Visual Studio 2010中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆