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

Impossible to add UseWindowsForms in a MAUI project #14970

Closed
guyvaio opened this issue May 8, 2023 · 15 comments
Closed

Impossible to add UseWindowsForms in a MAUI project #14970

guyvaio opened this issue May 8, 2023 · 15 comments
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@guyvaio
Copy link

guyvaio commented May 8, 2023

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.

@drasticactions drasticactions added the s/needs-repro Attach a solution or code which reproduces the issue label May 8, 2023
@ghost
Copy link

ghost commented May 8, 2023

Hi @guyvaio. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@drasticactions
Copy link
Contributor

drasticactions commented May 8, 2023

Most likely, your issue is already addressed in MAUI Main,

#14595 (comment)

#14331

Original Issue: #6450

@guyvaio
Copy link
Author

guyvaio commented May 8, 2023

Repro

  • create new project with ".NET MAUI App" template
  • Add true in project
  • In App.xaml.cs, replace App : Application by App : Microsoft.Maui.Controls.Application to prevent ambiguous reference
  • compile
  • got first error I mentionned

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels May 8, 2023
@drasticactions drasticactions added the s/needs-repro Attach a solution or code which reproduces the issue label May 8, 2023
@ghost
Copy link

ghost commented May 8, 2023

Hi @guyvaio. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@drasticactions
Copy link
Contributor

You need to create a repro project. This helps by removing chances of ambiguity and a way for both of us to verify that the changes work. I know it seems obvious to do, but it really helps.

@drasticactions drasticactions removed the s/needs-attention Issue has more information and needs another look label May 8, 2023
@guyvaio
Copy link
Author

guyvaio commented May 8, 2023

Repro project attached
TestMauiAppWin.zip

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels May 8, 2023
@drasticactions drasticactions added s/needs-repro Attach a solution or code which reproduces the issue and removed s/needs-attention Issue has more information and needs another look labels May 8, 2023
@ghost
Copy link

ghost commented May 8, 2023

Hi @guyvaio. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@drasticactions
Copy link
Contributor

I apologize; I should have specified this: Can you make this a public repo on GitHub or another source repository?

@jefh531
Copy link

jefh531 commented May 8, 2023

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels May 8, 2023
@Eilon Eilon added the area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label May 8, 2023
@mattleibow
Copy link
Member

I am not sure we support this on .NET 7. What happens if you target .NET 8?

@mattleibow mattleibow added s/needs-info Issue needs more info from the author and removed s/needs-attention Issue has more information and needs another look labels May 12, 2023
@ghost
Copy link

ghost commented May 12, 2023

Hi @guyvaio. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@guyvaio
Copy link
Author

guyvaio commented May 12, 2023

As mentioned in my first post : .net 7.0

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels May 12, 2023
@samhouts samhouts added the t/bug Something isn't working label Jul 31, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Jan 17, 2024
@Zhanglirong-Winnie Zhanglirong-Winnie added the s/triaged Issue has been reviewed label Jan 17, 2024
@Zhanglirong-Winnie
Copy link

Verified this issue with Visual Studio Enterprise 17.9.0 Preview 2.1. Can repro on Windows platforms with repro steps.
image

@PureWeen PureWeen added s/try-latest-version Please try to reproduce the potential issue on the latest public version and removed s/needs-attention Issue has more information and needs another look labels Apr 23, 2024
@guyvaio
Copy link
Author

guyvaio commented Apr 24, 2024

Not solved in Visual Studio 17.9.6

@dotnet-policy-service dotnet-policy-service bot removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Apr 24, 2024
@mattleibow mattleibow added this to the Backlog milestone Nov 19, 2024
@mattleibow
Copy link
Member

This happens with a plain WinUI app and I think this is all because we have conflicting compilers for XAML. We have MAUI, WinUI 3 and WPF all trying to build. Adding UseWindowsForms should be OK, but then it detects XAML and goes off on a error spree.

I don't think these are all meant to work together, and if they are, they were never tested as such. With MAUI and WPF/WinUI maybe we could get by as we have a MauiXaml build action, but both WPF and WinUI use Page, so this means it will never work without great effort.

Please open a bug for WinUI and WPF to address.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer 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

8 participants