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

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

问题描述

我整天都在努力让 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.

我安装了最新的 Mono for Windows,其中包括 GTK#.我还安装了一个 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-studioGridToGoGridToGoProgram.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!我什至尝试使用以下名称将 DLL 的 4 个副本复制到解决方案中的几乎每个文件夹中:.o glibsharpglie-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.

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

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

推荐答案

我想通了!Mono for Windows 完全没有必要..NET 的 GTK# 是我所需要的.对于将来想要为跨平台 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. 安装一个 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 的项目引用必要的程序集.

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

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