CLR20r3 DllNotFoundException for gtk-sharp, but it is installed

I installed the Gtk# package linked below to install Xamarin Studio:

I can build a Gtk# application, and it runs just fine with ctrl-F5 in Xamarin Studio. However, if I try to run it by double-clicking the EXE in Explorer, it fails with the following error:

Problem signature:
  Problem Event Name:   CLR20r3
  Problem Signature 01: nist80053.exe
  Problem Signature 02: 1.0.5046.16106
  Problem Signature 03: 526a86b5
  Problem Signature 04: gtk-sharp
  Problem Signature 05:
  Problem Signature 06: 51e446b5
  Problem Signature 07: 3c46
  Problem Signature 08: 16
  Problem Signature 09: System.DllNotFoundException
  OS Version:   6.1.7601.
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

I tried to ILmerge the DLL into the EXE, and it gave me a fascinating error about gtk-sharp.dll failed to merge, and was still an external reference. I'm really confused why it can't find the DLL, even if I put it in the same directory as the EXE, but it runs just fine in the IDE.


  • mhutchmhutch USMember, Xamarin Team Xamurai

    It's not entirely clear from the message, but it's possible that it's a native dll that's used by gtk-sharp that's not being loaded from your PATH, e.g. gtk+. You'll have to cath the exception and look at its details to be sure,and possibly review the Windows Fusion binding logs.

    I would suggest you use SetDllDirectory to set the path explicitly, like Xamarin Studio does.

  • jephthaijephthai USMember

    OK... I think I understand what you mean, but I frankly have no idea where I can catch an exception for when DLLs are loaded. Running with debugging is grayed out (and it runs in Xamarin Studio anyway), and as far as I know, "Main()" is my entry point?

    I'm running a fairly stock Windows 7 Pro. Are others able to run a GTK# hello world without this kind of workaround? I literally created a new GTK# project, compiled it, and tried to run it by double-clicking on the EXE.

  • jephthaijephthai USMember

    I fixed it. Well, I have a workaround anyway.

    I extracted all of the DLLs from the tree under C:\Program Files (x86)\GtkSharp, and did a binary search through them to figure out which ones needed to be copied into the same directory as my compiled Hello World application.

    I found that the following two were not being found properly as the referenced assemblies were loaded from the "installed" locations:


    By copying these into my current directory, the application loads just fine. I really don't know enough, myself, about .NET assemblies, references, and registration, etc. Is it possible that these two DLLs were either not properly registered somehow during the install, or could they be conflicting somehow with other versions of these DLLs installed with other software? (I do have some other open source apps that seem to have copies, such as Processing, Inkscape, etc.).

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Yes, those dlls need to be in your app's dll loading path.

    GTK# puts that directory in the PATH environment variable, which should work, but sometime doesn't seem to take for some reason. That's why I suggested taking the code from XS that looks up that location in the registry, then passes it to SetDllDirectory, so your app can load the dlls directly without you having to copy them to your app directory.

Sign In or Register to comment.