简体   繁体   English

当前上下文错误中不存在InitializeComponent

[英]InitializeComponent does not exist in the current context error

I'm getting this error on my Xamarin.Forms project whenever I try to create a Page with XAML+CS. 每当我尝试使用XAML + CS创建Page时,我的Xamarin.Forms项目都会出现此错误。

The namespace on the file corresponds: 文件上的名称空间对应于: 命名空间

And I've set the build action of the XAML Page to EmbeddedResource with the Custom Tool MSBuild:UpdateDesignTimeXaml . 并且我已使用自定义工具MSBuild:UpdateDesignTimeXaml将XAML页面的构建操作设置为EmbeddedResource
I checked the .csproj and it sets correctly the build action: 我检查了.csproj,它正确设置了构建操作:

  <ItemGroup>
    <EmbeddedResource Include="AppCore\Pages\SettingsPage.xaml">
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
      <SubType>Designer</SubType>
    </EmbeddedResource>
  </ItemGroup>

And: 和:

<Compile Include="AppCore\Pages\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>

Cleaning the solution and deleting the obj/bin folders didn't help and neither reinstalling the packages via update-package -project Travlendar.Core -reinstall . 清理解决方案并删除obj / bin文件夹无济于事,也没有通过update-package -project Travlendar.Core -reinstall重新安装软件包。

This is SettingsPage: 这是SettingsPage:

using Travlendar.Core.AppCore.ViewModels;
using Xamarin.Forms;

namespace Travlendar.Core.AppCore.Pages
{
    public partial class SettingsPage : ContentPage
    {
        public SettingsPage (INavigation navigation)
        {
            InitializeComponent ();
            BindingContext = new SettingsViewModel (this, navigation);
        }
    }
}

Found the solution, I had to delete the packages folder in the solution. 找到解决方案后,我不得不删除解决方案中的packages文件夹。
Then cleaning/re-building the solution and everything is working back. 然后清洗/重新构建解决方案,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当前上下文中不存在“ InitializeComponent” - 'InitializeComponent' does not exist in the current context 名称InitializeComponent在当前上下文中不存在 - The name InitializeComponent does not exist in the current context 当前上下文中不存在“InitializeComponent”和“_FrameViews” - The 'InitializeComponent' and '_FrameViews' does not exist in the current context 使用Visual Studio 2015打开WPF项目后,当前上下文错误中不存在名称“ InitializeComponent” - The name 'InitializeComponent' does not exist in the current context error after opening WPF project with Visual Studio 2015 新的WPF项目无法编译-引发错误“名称&#39;InitializeComponent&#39;在当前上下文中不存在” - New WPF Project Won't Compile — Throws Error “The name 'InitializeComponent' does not exist in the current context” 出现错误:“名称 InitializeComponent 在当前上下文中不存在”,在每个 xaml.cs class(Xamarin Forms)中 - Getting error: "The name InitializeComponent does not exist in the current context", in every xaml.cs class (Xamarin Forms) 当前上下文中不存在名称“InitializeComponent”(c#,xamarin) - The name 'InitializeComponent' does not exist in the current context(c#,xamarin) WPF应用程序中的当前上下文中不存在名称“InitializeComponent” - The name 'InitializeComponent' does not exist in the current context in WPF application InitializeComponent 在当前上下文中不存在,使用 Mono C# 编译器 - InitializeComponent does not exist in the current context, using Mono C# compiler 当前上下文中不存在名称“InitializeComponent” - The name 'InitializeComponent' doesn't exist in the current context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM