Bug 24013 - gtk-sharp.dll carries incomplete version information
Summary: gtk-sharp.dll carries incomplete version information
Alias: None
Product: Gtk#
Classification: Mono
Component: gtk-sharp ()
Version: 2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-10-23 11:00 UTC by Steffen
Modified: 2014-10-27 13:55 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

example gtk-sharp.dll (1.33 MB, application/x-msdownload)
2014-10-23 11:00 UTC, Steffen

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Steffen 2014-10-23 11:00:58 UTC
Created attachment 8481 [details]
example gtk-sharp.dll

The MSI installer for gtk-sharp for Windows from Xamarin (for example:


) delivers gtk-sharp.dll, for example to

C:\Program Files (x86)\GtkSharp\2.12\lib\gtk-sharp-2.0\gtk-sharp.dll

The version information of that DLL is incomplete. For all current gtk-sharp releases
(for example, 2.12.26), it simply claims to be version

However, my application needs to check that a specific version of that DLL is present
on the user machine. I.e., I need to specifically check that not ANY version of it is present,
but a version containing a specific bugfix (i.e. this one
) which has been cured with the release of gtk-sharp 2.12.26.

However, because the DLL "lies" about its real version number (it says "I am"
instead of "I am"), I cannot detect the presence of the proper version.


This issue requests to slightly correct the build process of that DLL to make it carry the proper version,
Comment 1 Steffen 2014-10-23 11:41:01 UTC
This problem seems to be important for more people than just me.

MonoDevelop needs to do the same check and currently contains
a workaround in its own implementation: the function CheckWindowsGtk()
as it is done here:


static bool CheckWindowsGtk ()
			string location = null;
			Version version = null;
			Version minVersion = new Version (2, 12, 22);

			using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Xamarin\GtkSharp\InstallFolder")) {
				if (key != null)
					location = key.GetValue (null) as string;
			using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Xamarin\GtkSharp\Version")) {
				if (key != null)
					Version.TryParse (key.GetValue (null) as string, out version);

			//TODO: check build version of GTK# dlls in GAC
			if (version == null || version < minVersion || location == null || !File.Exists (Path.Combine (location, "bin", "libgtk-win32-2.0-0.dll"))) {
				LoggingService.LogError ("Did not find required GTK# installation");
				string url = "http://monodevelop.com/Download";
				string caption = "Fatal Error";
				string message =
					"{0} did not find the required version of GTK#. Please click OK to open the download page, where " +
					"you can download and install the latest version.";
				if (DisplayWindowsOkCancelMessage (
					string.Format (message, BrandingService.ApplicationName, url), caption)
				) {
					Process.Start (url);
				return false;

			LoggingService.LogInfo ("Found GTK# version " + version);

			var path = Path.Combine (location, @"bin");
			try {
				if (SetDllDirectory (path)) {
					return true;
			} catch (EntryPointNotFoundException) {
			// this shouldn't happen unless something is weird in Windows
			LoggingService.LogError ("Unable to set GTK+ dll directory");
			return true;

However, that implementation is OS-specific and cumbersome.

I would much more prefer to be able to do this:

         Assembly gtksharp_assembly = Assembly.GetAssembly(typeof(Gtk.Application));
         string gtksharp_dll = gtksharp_assembly.Location;
         FileVersionInfo gtksharp_version = FileVersionInfo.GetVersionInfo(gtksharp_dll);

and then look into gtksharp_version to see the REAL dll version.
Comment 2 Mikayla Hutchinson [MSFT] 2014-10-27 11:29:11 UTC
This is intentional so that you can update GTK# without having to rebuild apps that are built against it.

I would recommend using the code from MonoDevelop. Note that it will show an error dialog even if GTK# is not installed *at all*, and also does some fixup of the native loader path to ensure that the correct version of GTK+ is loaded.
Comment 3 Steffen 2014-10-27 13:55:55 UTC
I understand.

However, having to fiddle with the Windows registry etc.
in this non-portable way is a little ugly.

Can't we add a gtk-sharp version number function
which would return the full information ?