-
Notifications
You must be signed in to change notification settings - Fork 693
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
How to use AppWindow in .NET Framework #9230
Comments
I used MoveAndResize without problem, for example at |
This problem occurs under the.net framework, and.NET core does not experience this problem. |
RectInt32 is a struct and not a runtime class. Could that be making a difference here? --Edit-- No, this isn't it. CS7063 is more like a reference not found error. After messing around a little, I don't see this. The application is also a .NET Framework 4.8.1 console application. To give some information on what I did to get this working.
I wrote a little P/Invoke wrapper for MddBootstrapInitialize2 and MddBootstrapShutdown, I also grabbed WindowsAppSDK-Version.cs from the NuGet packaged. Finally, I copied Microsoft.WindowsAppRuntime.Bootstrap.dll to the output directory. My references list was: The application worked, it had no issues activating AppWindow and the MoveAndResize call worked. |
I am also curious how this BUG happened, is this the dependency state of my application |
That is interesting. I also saw the same thing using the Microsoft.Windows.SDK.Contracts NuGet package, but referencing Windows.winmd directly works. What's more, ildasm shows that RectInt32 should be in Windows.Foundation.UniversalApiContract.winmd, but that can't satisfy the references and it wants Windows.winmd. |
I had been doing a bit more messing around, and this is possible to trigger in tools that just work with the metadata. The command line given in the first screenshot gives and the path to the files in the primary location where it is looking for metadata. A screenshot of which is given below. The highlighted files, especially Windows.Foundation.UniversalApiContract.winmd is where these definitions are. What is really more telling about this problem is that it fails to resolve types in Windows.Foundation.UniversalApiContract.winmd itself. The vast majority of these name resolution failures are from types contained in Windows.Foundation.UniversalApiContract.winmd. I would bet that some tools are assuming file name is equivalent to root namespace relations here. This would also apply to the SDK contracts NuGet package. As you can see, the .winmd files in this package are all the separate .winmd files. They are also named after the contract, and not the root namespace. Of course, I tested this out. I renamed Windows.Foundation.FoundationContract.winmd to Windows.Foundation.winmd, I renamed Windows.Foundation.UniversalApiContract.winmd to Windows.winmd, and Windows.Networking.Connectivity.WwanContract.winmd to Windows.Networking.Connectivity.winmd. In this case, winmdidl started finding the metadata. I really think this is either Visual Studio or the C# tools assuming a relationship between filename and contained namespaces in these metadata files. It would also explain why Visual Studio has no issues with the union metadata. |
I'm not sure what this reference assembly Windows.WINMD does. |
Describe the bug
How to use AppWindow in .NET Framework
在.NET Framework 中如何使用AppWindow
I tried to use some methods of AppWindow in.NET Framework (winform desktop application), found that some methods can not be called normally, would like to ask if there is any solution?
我在.NET Framework(winform 桌面应用程序)中尝试使用AppWindow的一些方法,发现部分方法不能正常调用,想问一下有没有什么解决方案?
Steps to reproduce the bug
As mentioned above
Expected behavior
当调用AppWindow的一些方法时,不再有红色错误提示
When some methods of the AppWindow are called, there is no longer a red error
Screenshots
As mentioned above
NuGet package version
Windows App SDK 1.4.3: 1.4.231115000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response
The text was updated successfully, but these errors were encountered: