1

与 Windows 2022 17.1。

我有一个在 Android、iOS、macOS 和 UWP 上运行的 xamarin 应用程序。

现在我在这个描述之后添加了一个 GTK 项目

我想创建一个独立的捆绑包。为此,我运行

mkbundle TimeDateCalculator.gtk.exe --simple -o timedatecalculator --cross mono-6.6.0-ubuntu-18

在窗户或

mkbundle -o timedatecalculator --simple TimeDateCalculator.gtk.exe --config /etc/mono/config --machine-config /etc/mono/4.5/machine.config

在wslg。

结果是:

ERROR: Unable to load assembly `netstandard' referenced by `/mnt/d/Users/eigil/projects/xamarinProjs/TimeDateCalculator/TimeDateCalculator/TimeDateCalculator.gtk/bin/Release/TimeDateCalculatorDll.dll'

为了解决我添加的问题

 <Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <Private>True</Private>
</Reference>

到 .gtk.csproj 文件。

现在mkbundle TimeDateCalculator.gtk.exe --simple -o timedatecalculator --cross mono-6.6.0-ubuntu-18Generated timedatecalculator

但是当我在 wslg (ubuntu 21.10) 中运行捆绑的应用程序时,结果如下:

    Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

我该如何解决这个问题?我试图将 gtk 项目目标框架从更改为.NET Framework 4.8.NET Framework 4.7但后来我得到了这个

Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Gtk.Container' threw an exception. ---> System.DllNotFoundException: gtksharpglue-2 assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset()
  at Gtk.Container..cctor () [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
   --- End of inner exception stack trace ---
  at Gtk.Bin..ctor (System.IntPtr raw) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
  at Gtk.Window..ctor (Gtk.WindowType type) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
  at Xamarin.Forms.Platform.GTK.FormsWindow..ctor () [0x00000] in <71d70d813d7b4bdea41b4cca10cb7120>:0
  at TimeDateCalculator.GTK.MainClass.Main (System.String[] args) [0x00011] in <856f5c6c1d224ab1a01e487cfe143ff6>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'Gtk.Container' threw an exception. ---> System.DllNotFoundException: gtksharpglue-2 assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Gtk.Container.gtksharp_gtk_container_get_focus_child_offset()
  at Gtk.Container..cctor () [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
   --- End of inner exception stack trace ---
  at Gtk.Bin..ctor (System.IntPtr raw) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
  at Gtk.Window..ctor (Gtk.WindowType type) [0x00000] in <35293b6aa2744433b0e2f41f34e699d5>:0
  at Xamarin.Forms.Platform.GTK.FormsWindow..ctor () [0x00000] in <71d70d813d7b4bdea41b4cca10cb7120>:0
  at TimeDateCalculator.GTK.MainClass.Main (System.String[] args) [0x00011] in <856f5c6c1d224ab1a01e487cfe143ff6>:0
4

0 回答 0