-
Notifications
You must be signed in to change notification settings - Fork 107
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
Self-contained WinRT components don't work. #1141
Comments
This is a blocking issue that, as currently implemented, is not possible with the
|
This should be easy to guarantee for packaged apps.
MSIX packaged apps are all self-contained (no other ways to guarantee .NET is on the machine), so this isn't a new concern for a self-contained WinRT component right? |
That is predicated that CsWinRT is only targeting MSIX scenarios. From my understanding, CsWinRT doesn't require a packaged installation so the general concept should be factored into the cost of support and document how one handles servicing .NET assets. |
Indeed CsWinRT doesn't require a packaged installation, but at the same time it currently doesn't block self-contained MSIX deployment and so I don't see any net-new concerns by allowing it for a WinRT component. |
An example of using https://github.com/AaronRobinsonMSFT/DNNE for self-contained components is here, in the NativeHost project of src/Samples/BgTaskComponent/BgTaskComponent.sln: https://github.com/jlaanstra/CsWinRT/tree/user/jlaans/self-contained |
@jlaanstra @AaronRobinsonMSFT - to clarify, is there a way to implement self-contained C# WinRT components, or is further work in CsWinRT required for that support? |
More work is needed. @jlaanstra was able to create a host that supports self-contained using DNNE but the built-in one needs to be updated to support the scenario. It is up to C#/WinRT to determine if self-contained is needed or not. There are UX and scenario limitations that need to be understood before officially supporting it. |
Thanks @AaronRobinsonMSFT. I've opened https://task.ms/39162576 to track this |
I'm trying to author a component (.NET 6) that will be consumed by:
This issue has me worried that my packaged scenarios won't work without .NET 6 being installed. Given that these scenarios revolve around installation/setup of systems, there is a very real possibility of it not being present. Am I understanding it correctly? Fortunately, I think we could bootstrap ourselves if needed, but I don't want for that to be a requirement if possible (it may even be explicitly blocked from being one). |
How is it possible this is unresolved for so long? It means the feature is pretty much unusable for MSIX / Windows App SDK? |
Tries to fix microsoft#1141. Uses the same approach as commited in https://github.com/jlaanstra/CsWinRT/tree/user/jlaans/self-contained microsoft#1141 (comment) with DNNE, but within CsWinRT directly, avoiding additional binaries.
I have looked into this myself and added self-contained support to CsWinRT in a fork, based on the implementation in #1141 (comment) but without DNNE and additional binaries. I can confirm the self-contained runtime is loaded as expected in the
You can also get the debugger to break on it, if you enable native debugging and set Visual Studio to break for Win32 Exceptions -> WinRT originate errors. This seems to be the same issue as with #1277, so there seems to be a more general problem here. To clarify, with the DNNE approach this error does not occur. |
We recently migrated to MSIX and .NET 8 with a self-contained deployment strategy, as MSIX inherently requires this approach. Our aim is to leverage background tasks, but this issue presents a significant blocker for our architecture. From my understanding, there is currently no way for self-contained apps to host out-of-proc WINRT component written in .NET. This limitation affects not only background tasks but also context menu handlers, push notifications, and potentially other features we intend to implement. The inability to use these functionalities restricts our application’s capabilities significantly. We’re keen to see if there are any upcoming solutions or workarounds that might help us address these challenges. |
FYI, you can use Native AOT now, which are self-contained. |
Only if you make the entire app NativeAOT, which currently is unfeasible with the amount of hurdles it has. It's not possible to have your authored component in a referenced project be NativeAOT and the main app project be self-contained. |
You don't need to, only the class library itself is required to use Native AOT. Native AOT deployment should not affect your main app. |
It does not work however, when setting
|
You package the two projects independently, not reference the AOT project in the non-AOT project. |
I guess that is a workaround, but a painful one. Having to build and distribute a NuGet package, especially for "local" projects, is far more complicated, than just referencing the project. Additionally, the AOT binary will be larger than just referencing existing runtime. |
WinRT components already work framework dependent. This issue is about self-contained deployments, which is already large. |
Yes, but having an AOT CsWinRT library next to a self-contained app in the same MSIX will also duplicate the runtime to some extent, even with trimming. |
Wouldn't it be the same if they both use self-contained regardless? |
No, the CsWinRT component and the app would use the same self-contained runtime within the same solution / MSIX package. No duplicates. |
I found out the error has something to do with the Normally, the Replacing the entire construct with a simple I don't know what the reason is and how to fix it yet, though. |
Describe the bug
WinRT.Host.dll doesn't work for a self-contained deployment. It requires .NET to be installed on the machine separately which can't be done with MSIX.
To Reproduce
Expected behavior
Toast task from the sample should work.
Actual behavior
Toast task does not work.
Version Info
CsWinRT 1.5.0
Additional context
N/A
The text was updated successfully, but these errors were encountered: