question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Xamarin Page and View Templates break MAUI Apps

See original GitHub issue

Description

When adding a ContentView or ContentPage to a .NET MAUI app using Visual Studio, it uses the Xamarin templates. Once you do this, the .NET MAUI app will no longer build.

I’m not sure if this is a MAUI issue or a Visual Studio 2022 issue - however, the build fails at the .NET CLI too.

Steps to Reproduce

  1. Build a new .NET MAUI app
  2. Using Visual Studio, add a ContentView or ContentPage
  3. Try to build and run your .NET MAUI app

Expected Behavior

The app builds and runs

Actual Behavior

Multiple compiler warnings are thrown for The name 'InitializeComponent' does not exist in the current context

Basic Information

  • Version with issue: .NET MAUI Preview 9
  • Last known good version: NA
  • IDE: Visual Studio 2022 17.0.0.0 Preview 7
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages: None
  • Affected Devices: All

Screenshots

Reproduction Link

Workaround

With limited success, removing the views or pages added with the Xamarin templates, deleting the bin and obj folders (specifically obj) and cleaning/rebuilding the solution, you can run your app. This workaround does not work consistently though - probably because I have been unable to extricate all the of the Xamarin references.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Eiloncommented, Nov 1, 2021

Eep! I think if the Xamarin.Forms item templates for ContentView and ContentPage show up then we need to make sure those get hidden from .NET MAUI apps. .NET MAUI does have its own ContentView and ContentPage item templates. For some reason in VS I see only the Xamarin.Forms versions but in the command line (dotnet new ...) I see the .NET MAUI ones.

1reaction
Xami3Shahcommented, Nov 1, 2021

whenever i create page with vs2022 then i have to remove the first line which contains

<?xml version="1.0" encoding="UTF-8"?>

and also the code for this page from csproj file. then it works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot known issues - .NET MAUI
NET Multi-platform App UI (.NET MAUI), and how you can solve or work around them. The .NET MAUI repository also details some known...
Read more >
I updated a Xamarin Forms project to Maui - Brad Dean
For my sample project I just created the blank Xamarin Forms Template. It's a very simple app so we won't be seeing how...
Read more >
Did .NET MAUI Ship Too Soon? Devs Sound Off on ' ...
As I've used to be a Xamarin dev I can tell MAUI won't be stable for a year. I've worked deeply on an...
Read more >
Create multi-page .NET MAUI apps with tab and flyout ...
Learn Live - Create multi-page .NET MAUI apps with tab and flyout navigation. 8.7K views · Streamed 9 months ago ...more ...
Read more >
Prism for .NET MAUI - Public Beta - Dan Siegel
Dan Siegel - Building Better Apps - Ok the name kind of gives it away, but Prism for .NET MAUI is now available...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found