簡體   English   中英

Xamarin.Forms:無法解析程序集或Windows元數據文件“類型Universe無法解析程序集:MyApp.UI.Base…”

[英]Xamarin.Forms: Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: MyApp.UI.Base…'

我有一個Xamarin.Forms應用程序。 該項目的結構比常規Xamarin.Forms解決方案要復雜得多。

我有特定於平台的項目:

  • MyApp.Android
  • MyApp.iOS
  • MyApp.UWP

我有一個用於.xaml頁面定義的.net標准庫項目:

  • MyApp.UI(由特定於平台的項目引用)

我有一個.net標准庫項目,用於.xaml頁面基類:

  • MyApp.UI.Base(由MyApp.UI引用)

我在MyApp.UI.Base中有一個PageBase類。 假設我有這樣的Login.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<base:PageBase xmlns="http://xamarin.com/schemas/2014/forms"
               xmlns:base="clr-namespace:MyApp.UI.Base;assembly=MyApp.UI.Base" ...>
...
</base:PageBase>

Login.cs中的類型也正確:

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Login : PageBase
{
// ...
}

編譯解決方案時,出現以下錯誤:

無法解析程序集或Windows元數據文件“類型Universe無法解析程序集:MyApp.UI.Base,版本= 1.0.0.0,區域性=中性,PublicKeyToken =空。”

這個錯誤似乎是完全錯誤的,我嘗試了其他解決方案,例如刪除.vs文件夾或還原nuget程序包,但是它們都不起作用。

不能有來自不同程序集的xaml頁面的基類嗎?

問題是MyApp.UWP項目沒有引用項目MyApp.UI.Base。 添加參考即可解決此問題。 我猜錯誤是對的,只是不完全正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM