-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Referencing a MAUI library gives "Type 'App' already defines a member called 'InitializeComponent' with the same parameter types" #10113
Comments
Since the executable is WPF and MAUI is only a library, I am not sure why MAUI should be generating an app class. Perhaps this would be more useful in dotnet/maui than here. |
@miloush The issue seems to be deeper than simply Maui defining a class called "App". If I create a new WPF XAML file with any name, the compiler complains that In other words, referencing a Maui library completely prevents any WPF XAML component from compiling, with ridiculous error messages. |
Sounds like MAUI library is bringing in source generators to the project that run on XAML files. |
I'm not sure what that means. Do you know of any way to stop or workaround that? |
You can disable source generators, for example in the project file: <Project>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" />
</ItemGroup>
</Target>
</Project> This disables them all. You can disable specific ones, but you need a path. I am not set up to run MAUI projects, so you have to find out yourself in the solution explorer: |
|
The latest comment resolved the issue. For posterity, you need to open the .csproj for the WPF project in a text editor, and add the above line inside of the |
Description
I'm not sure if this is a WPF bug, a MAUI bug, Visual Studio, Roslyn, etc.
With the latest VS/Maui/WPF/.Net, if you have a WPF app and reference a MAUI Class Library, the WPF application suddenly stops compiling with weird errors, even in a brand new WPF project with no changes from the defaults.
Specifically, the following files are generated by Visual Studio when creating a new WPF project:
App.xaml
App.xaml.cs
And results in the following errors:
The second error (which is confusing because the code is already specifying
using System.Windows
) can be fixed by changingApp : Application
toApp : System.Windows.Application
, but the first error seems to be unfixable on our end.Reproduction Steps
Expected behavior
App compiles successfully
Actual behavior
Compiler gives non-sensical, unfixable compilation errors
Regression?
No, this is new behavior. It was working prior to upgrading to .Net 9
Known Workarounds
none
Impact
MAJOR. App is now completely uncompilable.
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: