为什么我在 Visual Studio 2019 Windows 运行 我的 Xamarin GTK 项目时得到这个 System.DllNotFoundException?

Why am I getting this System.DllNotFoundException when running my Xamarin GTK project in Visual Studio 2019 for Windows?

我的团队正在开发一个 Xamarin 项目,该项目 运行 在 Linux 上使用 GTK。我们主要使用 Visual Studio 2019 进行构建和测试。我已经为 .NET 和 Mono 安装了 GTK#。我们团队的其他成员在他们的机器上 运行 在 Windows 中设置 GTK 项目没有问题,但是当我将我的 GTK 项目设置为启动项目并且 运行 它时,我收到以下错误:

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)

我知道有些人在他们的系统上没有设置正确的 PATH 时会遇到这个问题,但据我所知这不是问题所在。我还确保 libgtk-win32-2.0-0.dll 存在于两个安装中。我有两个硬盘驱动器:C:,我的系统驱动器,和 D: 我的 HDD,它是 Visual Studio 和项目本身所在的位置。我尝试在两个驱动器上安装 GTK# for .NET,并将 GTK /bin 目录和 mono \bin 目录添加到 PATH 系统变量。我在下面包含了我的整个路径系统变量文本:

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.12\bin;
C:\Program Files\Microsoft SQL Server0\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\ODBC0\Tools\Binn\;
C:\Program Files (x86)\GtkSharp.12\bin;
C:\Program Files (x86)\Mono\bin;

下面我还包含了 Visual Studio 输出 window 的内容,以防有帮助:

'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 Studio19\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.

我的环境是Windows10,我用的是Visual Studio2019.

我不确定下一步该做什么或我可以进行哪些其他更改。我已经尝试寻找解决方案,但几乎没有任何解决方案,据我所知,none 存在不需要我以可能影响它对我的团队成员的工作方式的方式更改项目,或者当 运行 在实际的 Linux 设备上安装它时(这是最终目标)。对此的任何见解将不胜感激。

我发现这个添加的功能可以解决使用 this CheckWindowsGTK() method and its platform check 启动时的问题。相关代码在启动文件中。