页面不包含X的定义

问题描述:

在开发过程中,我有一个TempTextBlock进行测试,现在我已将其删除。它成功地建立,但是当我尝试创建一个包店,它给出了这样的错误:页面不包含X的定义

error CS1061: 'MainPage' does not contain a definition for 'TempTextBlock' and no extension method 'TempTextBlock' accepting a first argument of type 'MainPage' could be found (are you missing a using directive or an assembly reference?)

MainPage.g.cs我看到这一点:

/// <summary> 
/// Connect() 
/// </summary> 
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Windows.UI.Xaml.Build.Tasks"," 14.0.0.0")] 
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
public void Connect(int connectionId, object target) 
{ 
    switch(connectionId) 
    { 
    case 1: 
     { 
      this.TempTextBlock = (global::Windows.UI.Xaml.Controls.TextBlock)(target); 
     } 
     break; 
    default: 
     break; 
    } 
    this._contentLoaded = true; 
} 

所以TempTextBlock使用那里。如果我删除整个方法,给出了这样的错误:

error CS0535: 'MainPage' does not implement interface member 'IComponentConnector.Connect(int, object)'

那是什么Connect方法MainPage.g.cs以及如何解决这个问题?谢谢。

+0

如果删除this.TempTextBlock = ...会发生什么情况,并用continue继续; – jameswassinger

对我来说: 删除整个`\ obj'文件夹。

Visual Studio 2017因任何原因未能创建自动生成的文件。

您应该使用Build > Clean Solution来清除解决方案中的所有自动生成的代码。