Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page doesn't contain a definition for X

During development I had a TempTextBlock for testing and I've removed it now. It builds successfully, but when I try to create a package for store, it gives this error:

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?)

In MainPage.g.cs I see this:

/// <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;
}

So TempTextBlock is used there. If I remove the whole method, it gives this error:

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

What's that Connect method in MainPage.g.cs and how to resolve this issue? thanks.

like image 370
Blendester Avatar asked May 06 '17 03:05

Blendester


1 Answers

For me in the future: Delete entire `\obj' folder.

Visual Studio 2017 failed to create auto generated files for any reason.

like image 181
Blendester Avatar answered Oct 20 '22 21:10

Blendester