Skip to content

Impossible to add UseWindowsForms in a MAUI project #14970

@guyvaio

Description

@guyvaio

I've created a new MAUI project 7.0. In this project I need to reference an assembly compiled against .net 7.0 but with <UseWindowsForms>true</UseWindowsForms>. So I need to add <UseWindowsForms>true</UseWindowsForms> in the project.

When adding this line, the project does not compile anymore and claims for: "Project file must include the .NET Framework assembly 'PresentationCore, PresentationFramework' in the reference list. ... Microsoft.WinFX.targets".

I understand I have to add this line in the MAUI project (not needed in my case): <UseWPF>true</UseWPF>.

Consequently I get this error: 'App' does not contain a definition for 'InitializeComponent'

Tried to force build action to MauiXaml for all XAML files.

if I replace all XAM file by their equivalent cs files, I can add UseWindowsForms without UseWpf and everything works fine.

Seems that when UseWindowsForms is added and XAML files exist, WPF is required, even though there is no XAML files for WPF.

Visual Studio 17.5.5 has been restarted several times. Bin and Obj directories have been manually deleted several times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-single-projectSplash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizers/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions