2012-07-05 10 views
12

私は素敵なクロスプラットフォームのGUIアプリケーションを書き始めることができるようにのWindows Server 2008 R2 x64の上のVisual Studio 2010で作業GTK番号を取得するために、すべての日をしようとしてきたが、私はやや新たなんですC#と私はトラブルの世界を持っています。GTKの#2010

私はGTKの#を含むWindows用の最新のMonoをインストールしました。 http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/

私は新しいWindows Formsアプリケーションを作成し、Windowsフォームのものへの参照を削除し、GTK#の参照を追加しました。このプロジェクトの目標フレームワークになるモノ2.10.8プロファイルをインストールしました。ここからの案内にゆるやかに従います:http://jrwren.wrenfam.com/blog/2008/11/01/gtk-in-visual-studio-2008-on-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(); 
     } 
    } 
} 

私は任意の構成でこれを実行しようとすると、私は次の例外を取得:

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を見つけるために! glibsharpglue-2glibsharpglue-2.dllglibsharpglue-2.oglibsharpglue-2.o.dll:私も次の名前の溶液中のほとんどすべてのフォルダにDLLの4つのコピーをコピーしてみました! GTKサイトからGTKオールインワンパッケージをインストールしてbinパスを自分のシステムパスに追加しようとしたところ、同じ4つのdllファイルをそのフォルダにコピーしても問題ありませんでした。

私の狂気の問題のために何かアドバイス?私はここで何か大きなものを逃しているように感じる。 > _ <

答えて

19

私はそれを考え出しました! Mono for Windowsはまったく必要ありませんでした。 GTK#for .NETは私にとって必要なものです。ここでは、クロスプラットフォームのGTK#の開発のための彼らのWindows環境をセットアップしたい将来的に誰のために私が続く手順は次のとおりです。

  1. は、ここからの指示でMonoプロジェクトのターゲットをインストールします。http://erictummers.wordpress.com/2012/01/25/target-mono-from-visual-studio/
  2. はのためのGTK#をインストールします。 .NETの公式Monoダウンロードサイトから。
  3. Windows用のGlade/GTK +、sourceforgeプロジェクトをここにインストールしてください:http://sourceforge.net/projects/gladewin32/
  4. Monoを対象とした新しいC#プロジェクトを作成してください。
  5. .NET用のGTK#をインストールした場所からプロジェクトに必要なアセンブリを参照してください。
+1

MonoのWindows.Formsのクロスプラットフォームは、そのすべてが賢明ではありませんが... – ruffin

+0

戻って説明してくれてありがとう! – heltonbiker

+0

私は興味があります、なぜモノをターゲットにしたいですか? MicrosoftのVisual C#コンパイラを使用する際に問題がありますか?モノとMicrosoftのどちらのコンパイラでも、MonoのランタイムまたはMicrosoftの.NETランタイムで実行可能なバイナリを製品化できると思います。 –