Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The name 'InitializeComponent' does not exist in the current context still is not fixed! #23805

Open
mobynet1 opened this issue Jul 24, 2024 · 4 comments
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@mobynet1
Copy link

mobynet1 commented Jul 24, 2024

Description

This has been an issue since .NET 5. I just reviewed the issues history and have seen many reports and they have all been closed, but this issue is not fixed. I have been on the verge of dumping MAUI and turning to Avalon or Uno because of these weird types of issues being a continual source of frustration.

I have been working on my app since MAUI pre-release days. I have tried to contribute to the issues list in a constructive manner, but eventually the frustration simply exceeds my capacity to be patient. At that point I tend to get overly terse, which I know is not constructive, but it does get your attention...

I have seen where a simple change the .csproj file causes MAUI to just lose its mind. Suddenly none of the items in a xaml code-behind are bound to the xaml itself. In the past, I have had to spend hours recreating the entire solution to get around this issue. Yesterday, I had been running my app in preparation of creating a beta release when all of the sudden nothing compiles. It ran one minute, then after I added some comments to the project file, everything came to a screeching halt. I have no idea how to reproduce this, but it has happened to me at least five times and I am just about to pull the plug.

I have 10 pages, the shell, and the app files that have all become afflicted. I delete the files, add them back in and still no go. I have created new pages altogether and still no go. I delete the bin and obj folders, clean, you name it and the issue remains. There is something wrong with the way the project file is processed after being manually edited.

There are many reasons that require manually editing the project file. The <EnablePreviewFeatures> tag, for instance, needs to be added. I need to publish an upackaged app and that requires edits to the project file. I see warnings which are harmless but I detest seeing them in the build logs so I add <NoWarn> flags. I had been successfully building and running the app until I added the following 2 comments to the project file:

<!--
    The use of this property will cause the following warning in the publising of the application:

    message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy 
    [C:\Development\MobyNet\Dev\MobyClient\MobyClient\MobyClient.csproj::TargetFramework=net8.0-windows10.0.19041.0]

    This warning can be objectively ignored.
-->
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<!-- 
    The NoWarn property will suppress the following C# compiler warnings:
    "The field 'field name' is never used" (CS0169),
    "Field 'field name' is never assigned to, and will always have its default value null" (CS0649), and
    "This async method lacks 'await' operators and will run synchronously" (CS1998)
-->
<NoWarn>CS0169;CS0649;CS1998</NoWarn>

The issues highlighted by these warnings will eventually be cleaned up, but I simply do not want to see this in my build logs.

And

<!-- Publish MobyClient as an unpackaged app. This step works around a bug in the Windows App SDK. -->
<!--<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''">
    <RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier>
</PropertyGroup>-->

<!--
    The dotnet command to publish the app manually is:

    dotnet publish -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 - 
   p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true

    -f: Target framework (e.g., net8.0-windows10.0.19041.0).
    -c: Build configuration (Release).
    -p:RuntimeIdentifierOverride: Avoids the bug mentioned earlier.
    -p:WindowsPackageType: Set to None for unpackaged apps.
    -p:WindowsAppSDKSelfContained: Set to true for self-contained apps.

    The built app will be in the bin/Release/net8.0-windows10.0.19041.0/win10-x64/publish folder as an .exe file.
-->

In an attempt to clean this up without having to rebuild the whole solution (which is the only way I have been able to get around this very annoying issue), I deleted the App.xaml/App.xaml.cs files, re-add the item anew, with no edits whatsoever and get this:

Screenshot 2024-07-24 061106

The old, red squiggly line of death... Very annoying. Very disappointing...

After the last edit, the app simply will not build. Every single .xaml/.xaml.cs become unbound and almost every single control added to the page becomes does not exist in the current context. On top of that, the code-generated items produced by the CommunityToolkit.xxx won't build. I do not know if that is related or what... It could be... The encoding of some of the files is LF while others are MIXED. I do not know if that is related or not, either.

I just don't want to have to do this again and again.......... :-(

Steps to Reproduce

  1. Create a new MAUI app.
  2. Build it and be happy.
  3. Change something in the .csproj file
  4. Suddenly nothing builds
  5. Be sad and completely frustrated.

It is as simple as that. All the way back to pre-release days...

Link to public reproduction project repository

I have done this many times before and will not take the time to do it again...

Version with bug

net8.0-android;net8.0-ios;net8.0-maccatalyst

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net8.0-windows10.0.19041.0

Did you find any workaround?

Yes... rebuild the whole $*&%@! app from scratch which takes hours of wasted, unproductive time.

Since it seems I cannot add a screenshot to the 'Relavent log output', here that is:

Screenshot 2024-07-24 062906

and so on, and so on...

Relevant log output

No response

@mobynet1 mobynet1 added the t/bug Something isn't working label Jul 24, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@samhouts samhouts added platform/windows 🪟 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jul 24, 2024
@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed and removed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jul 30, 2024
@RoiChen001
Copy link

RoiChen001 commented Jul 30, 2024

I have encountered this problem in previous tests, but the error will disappear after reopening the App. This is not stable. If I reproduce it again later, I will collect the log and provide it here.

@mobynet1
Copy link
Author

I just updated VS2022 to v17.11.0 and VS2022 Preview to v.17.12 p1.0 and the issue is still present.

@samhouts samhouts added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 28, 2024
@azhkyaw
Copy link

azhkyaw commented Aug 30, 2024

I'm on VS2022 v17.11.2 and experiencing the same issue. Cleaning or rebuilding hasn't resolved it for me.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-xaml XAML, CSS, Triggers, Behaviors platform/windows 🪟 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants