netstandard 问题。 mono-6.6.0-ubuntu-18

问题描述 投票:0回答:1

VS Windows 2022 17.1。

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

现在我按照this描述添加了一个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-18
给出
Generated 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
ubuntu gtk visual-studio-2022 mkbundle
1个回答
0
投票

我知道这是一个super老问题,但我遇到了同样的问题并找到了解决方案,即手动将“netstandard”的外观库添加到 mkbundle 命令中:

mkbundle ..... myApp.exe "$LibPath45/Facades/netstandard.dll"

在我的例子中 LibPath45 是 /usr/local/lib/mono/4.5

© www.soinside.com 2019 - 2024. All rights reserved.