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

Unable to build WinUI 3 app with WinForms enabled #3211

Closed
shinta0806 opened this issue Dec 4, 2022 · 6 comments
Closed

Unable to build WinUI 3 app with WinForms enabled #3211

shinta0806 opened this issue Dec 4, 2022 · 6 comments

Comments

@shinta0806
Copy link

Describe the bug

In WinUI 3 project, build errors occur with WinForms enabled.

Steps to reproduce the bug

  1. Create new WinUI 3 project (Empty packaged app, Desktop WinUI 3). Build OK.
  2. Enable Windows Forms in project property.
  3. MC6000 error (project needs PresentasionCore, PresentationFramework) occurs.
  4. Try to enable WPF in project property.
  5. MC3074 error (tag 'XamlControlsResources' doesn't exist in XML namespace 'using:Microsoft.UI.Xaml.Controls') occurs.

Project files are:
https://github.com/shinta0806/TestWinUi3WithForms

Expected behavior

No response

Screenshots

New WinUI 3 project:
1

Enable Windows Forms:
2

MC6000 error:
2a

Enable WPF:
3

MC3074 error:
4

NuGet package version

Windows App SDK 1.2.1: 1.2.221116.1

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

Visual Studio 2022 Version 17.4.2

@christosk92
Copy link

Frameworkが全然違うので、WinUI 3でWinformsは使えないと思うんですけど..

@shinta0806
Copy link
Author

shinta0806 commented Dec 5, 2022

I have not explained myself well enough, but first, my purpose for wanting to use WinForms is because I think that the Windows App SDK alone may not have enough functionality yet. For example, I think it would be easier to handle multiple displays with WinForms (System.Windows.Forms.Screen).

And you can use both frameworks even if they are totally different. For example, you can use WinForms classes in WPF. And even controls can be used, since there is a WindowsFormsHost.

If the Windows App SDK is exclusive to other frameworks, then I would prefer not to see the option to enable WinForms or WPF.

@castorix
Copy link

castorix commented Dec 5, 2022

You can use WinForms classes by adding Reference to System.Windows.Forms.dll and other DLLs
(from C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App\ ...)
But it is usually not needed, as you can use any Win32 API in WinUI (P/Invoke in C#), which are also used by WinForms...

@shinta0806
Copy link
Author

Thanks for the information.

@gabbybilka
Copy link
Member

We aren't prioritizing building WinUI 3 apps with WinForms classes at this time. However, it looks like you have the information you need for this scenario. Thanks @castorix for hopping in.

@shinta0806
Copy link
Author

This was resolved by splitting the project within the Solution.
https://zenn.dev/shinta0806/articles/winui3-winforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants