在 Xamarin Forms 从 4.7 到 4.8.0.1560 版本,在 Xamarin Forms 构建 WPF 版项目也许会提示 XamlC error XFC0000 : Cannot resolve type “Application” 构建失败

提示内容如下

App.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "Application".
AppShell.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "Shell".
Views/AboutPage.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "ContentPage".
Views/ItemDetailPage.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "ContentPage".
Views/ItemsPage.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "ContentPage".
Views/NewItemPage.xaml : error :  : XamlC error XFC0000 : Cannot resolve type "ContentPage".

[Bug] XAML compiler broke with 4.7.0 · Issue #11101 · xamarin/Xamarin.Forms 所说,一个可以使用的方法是 Michael Schnerring 大佬提供的方法

在 csproj 中添加如下代码

<ItemGroup>
    <EmbeddedResource Remove="**/*.xaml" />
</ItemGroup>

详细请看 https://github.com/xamarin/Xamarin.Forms/issues/11101#issuecomment-678329339

另一个方法是我的方法,删除所有的 App.xaml 和 MainWindow.xaml 等文件,如 https://github.com/lindexi/lindexi_gd/tree/96c9063fdba9fe318eb099da67422de5cc9ae5af/XamarinNeller/XamarinNeller.WPF 项目所示,这样也能构建成功。细节请看 WPF 从零手动创建承载 Xamarin Forms 项目


本文会经常更新,请阅读原文: https://blog.lindexi.com/post/Xamarin-Forms-%E6%9E%84%E5%BB%BA-WPF-%E7%89%88%E9%A1%B9%E7%9B%AE%E5%A4%B1%E8%B4%A5%E6%8F%90%E7%A4%BA-XamlC-error-XFC0000-%E9%94%99%E8%AF%AF.html ,以避免陈旧错误知识的误导,同时有更好的阅读体验。

如果你想持续阅读我的最新博客,请点击 RSS 订阅,推荐使用RSS Stalker订阅博客,或者收藏我的博客导航

知识共享许可协议 本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接: https://blog.lindexi.com ),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请 与我联系

微软最具价值专家


无盈利,不卖课,做纯粹的技术博客

以下是广告时间

推荐关注 Edi.Wang 的公众号

欢迎进入 Eleven 老师组建的 .NET 社区

以上广告全是友情推广,无盈利