SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Matt Ward

SharpDevelop2 and Mono's GAC

In revision 983 SharpDevelop2 has support for Mono's GAC.  It also includes new Gtk# and Glade# project templates, and a Gtk# Window file template.  Mono can be downloaded from here

Creating a new Glade# Project
  1. Select the menu option File | New | Solution to open the "New Project" dialog.
  2. Select the C# category.
  3. There are two new projects here, a Gtk# project and a Glade# project.  Select the Glade# project.



  4. Enter a name for the project and select the "Create" button to generate the project.



The generated project will target Mono 1.1 by default, and will use Mono's Mcs compiler.

Running the Glade# Application

If you have the Mono bin directory (e.g. C:\Program Files\Mono\bin) added to your Path environment variable, the project can be started by selecting the menu option Debug | Run or Debug | Run without debugger. This will run the application under the Microsoft .NET framework and not Mono itself, to run under Mono see this post.

Note that you cannot debug the application when it is built with either of the Mono compilers.

Adding a Mono GAC Reference
  1. Open the Project Browser via View | Project.
  2. Select the "References" node, right click and select "Add Mono Reference". 



  3. Select the GAC entry that will be added to the project, click the Select button and then click the OK button to add the reference to the project.


Code Completion


There is a small problem with code auto-completion.  In order for auto-completion to work the reference must be added via the "Add Mono Reference" dialog.  So the first time a Glade# or Gtk# project has been created you will have to remove the GAC references and then re-add them to get code auto-completion working.  This only needs to be done once, not every time a Gtk# or Glade# project is created.

Debugging a Mono Application

You cannot debug a Mono app built using Mcs or Gmcs.  The Mono compilers create their own open source debugging symbols binary (.mdb) which SharpDevelop and Microsoft's DbgCLR do not support.  There is also no Mono debugger available for Windows.  In order to debug a Mono app it needs to be built using the Microsoft Csc compiler.  The general guidelines to be able to debug your Mono app using the SharpDevelop debugger are:
  1. Make sure all Mono specific GAC references have "Local Copy" set to true.  Select the reference in the Project Browser and select Properties to set this.
  2. The Mono bin directory (e.g. C:\Program Files\Mono\bin) must be added to the Path environment variable.
  3. Change the "Target Framework" (Project | Project Options | Compiling) to one of the Microsoft .NET frameworks.
  4. Remove and re-add your Mono GAC references using the "Add Mono Reference" dialog.  You should only need to do this once and only if you are using a project created from the Glade# or Gtk# templates.  Doing this will add a HintPath to the references in your MSBuild project so the Microsoft compilers can locate the assemblies in the Mono GAC.  These HintPaths are not currently added to a newly created Glade/Gtk# project.
  5. Rebuild your application.
Once the HintPaths have been added to your MSBuild project you should be able to switch between the Microsoft and Mono frameworks as required, and build your code using the Microsoft or Mono compilers.

If you are going to debug a Gtk# or Glade# application you will need to add extra GAC references.  Mcs and Gmcs do not need all Gtk# references to be added, but Microsoft's Csc compiler does.  For a Gtk# app you will need at least:
  • atk-sharp
  • gdk-sharp
  • glib-sharp
  • gtk-sharp
  • pango-sharp
Also add glade-sharp if you are developing a Glade# app.

Links

Mono Downloads
Targeting Mono with SharpDevelop2
SharpDevelop Daily Builds
Published Jan 10 2006, 01:43 PM by MattWard
Filed under:

Comments

 

Matt Ward said:

The starting point is the Glade xml file.
Glade xml file
This was created using the Glade UI Builder...
Januar 10, 2006 3:15 PM
 

zak said:

This is execellent. I have been able to work with Glade# and Mono using SD 2.0 already (using Matt's previous posts), but this really made my day. Oh, yeah if any one is wondering, SharpDevelop is awesome, it is 1 out of 2 apps total keeping my NTFS partition intact.
Januar 10, 2006 3:27 PM
 

GDragoN said:

I have just tried newest SD2 build and I have big problem with Glade# project. When I make it, and then just try to run it, I get empty form followed by debugger reporting error:
------------------------
Exception System.InvalidCastException was thrown in debugee:
Specified cast is not valid.

CreateObject()
GetObject()
ConnectFunc()
Autoconnect()
Autoconnect()
.ctor()
Main()
---------------------------------

Also, I think that glade xml file should have different extension (.glade like in VS2003), so it cound be opened by Glade and edited.
Januar 23, 2006 1:42 AM
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.