My team is working on a Xamarin project that runs on Linux using GTK. We are primarily using Visual Studio 2019 for building and testing. I have installed GTK# for .NET as well as Mono. The rest of our team has no problem running the GTK project in Windows on their machine but when I set my GTK project as the startup project and run it I get the following error:
Exception thrown: 'System.DllNotFoundException' in gtk-sharp.dll
An unhandled exception of type 'System.DllNotFoundException' occurred in gtk-sharp.dll
Unable to load DLL 'libgtk-win32-2.0-0.dll': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)
I understand that some folks get this issue if the correct PATH is not set on their system, but as far as I can tell this is not the issue. I've also ensured that libgtk-win32-2.0-0.dll
is present in both installations. I have two hard drives: C:, my system drive, and D: my HDD which is where Visual Studio and the project itself live. I've attempted installing GTK# for .NET on both drives and adding both GTK /bin directories as well as the mono \bin directory to PATH System Variable. I've included my entire Path System Variable text below:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\ProgramData\Oracle\Java\javapath;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Python34;
C:\Python34\Scripts;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
D:\Program Files\Java\jdk1.7.0_80\bin;
D:\Programming\MinGW\bin;
C:\Program Files (x86)\GtkSharp\2.12\bin;
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;
C:\Program Files (x86)\MySQL\MySQL Server 5.7\bin;
D:\Program Files\Git\cmd;
D:\Program Files\Notepad++;%SYSTEMROOT%\System32\OpenSSH\;
C:\Program Files\dotnet\;
D:\Programming\Python\Anaconda3;
C:\Users\Blake\AppData\Roaming\jupyter;
D:\Program Files (x86)\Brackets\command;
D:\cygwin\bin;
C:\Program Files\nodejs\;
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;
C:\Program Files (x86)\GtkSharp\2.12\bin;
C:\Program Files (x86)\Mono\bin;
Below I've also included the contents of Visual Studio Output window in case that helps at all:
'TestProject.GTK.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'D:\Programming\Xamarin\test-project\TestProject.GTK\bin\Debug\TestProject.GTK.exe'. Symbols loaded.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\gtk-sharp\v4.0_2.12.0.0__35e10195dab3c99f\gtk-sharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'D:\Programming\Xamarin\test-project\TestProject.GTK\bin\Debug\Xamarin.Forms.Platform.GTK.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'D:\Programming\Xamarin\test-project\TestProject.GTK\bin\Debug\TestProject.dll'. Symbols loaded.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'D:\Programming\Xamarin\test-project\TestProject.GTK\bin\Debug\Xamarin.Forms.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\glib-sharp\v4.0_2.12.0.0__35e10195dab3c99f\glib-sharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\atk-sharp\v4.0_2.12.0.0__35e10195dab3c99f\atk-sharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\gdk-sharp\v4.0_2.12.0.0__35e10195dab3c99f\gdk-sharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Exception thrown: 'System.DllNotFoundException' in gtk-sharp.dll
An unhandled exception of type 'System.DllNotFoundException' occurred in gtk-sharp.dll
Unable to load DLL 'libgtk-win32-2.0-0.dll': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F)
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TestProject.GTK.exe' (CLR v4.0.30319: TestProject.GTK.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
My environment is Windows 10 and I am using Visual Studio 2019.
I'm not sure what to do next or what other changes I can make. I've tried searching for solutions but barely any exist and, as far as I can tell, none exist that don't require me to change the project in a way that might affect how it works for my team members, or when running it on an actual Linux device (which is the end goal). Any insight into this would be highly appreciated.
I found this added functionality which resolves the issue on startup using this CheckWindowsGTK() method and its platform check. The relevant code goes in the startup file.
User contributions licensed under CC BY-SA 3.0