Question: Can Reunion be used to make a UWP library version independent? #377
Replies: 7 comments
-
Apps can use the pattern documented here https://docs.microsoft.com/en-us/uwp/api/windows.foundation.metadata.apiinformation.ismethodpresent?view=winrt-19041, and we expect to make that easier to use with Reunion with polyfills. Is there a specific API that you'd like Reunion to help you with? |
Beta Was this translation helpful? Give feedback.
-
The API that we're trying to access is https://docs.microsoft.com/en-us/uwp/api/windows.ui.windowmanagement.displayregion?view=winrt-18362 Windows.UI.WindowManagement.DisplayRegion, in order to use the WorkAreaOffset to calculate the offset to the visible bounds for an ad. Part of the difficulty we ran into was this, which I realize in retrospect I should've included with the original post - https://stackoverflow.com/questions/47540577/does-apiinformation-not-respect-the-app-target-version The big issue we ran into: "A different problem can occur if you include a higher-versioned .NET library inside a lower-versioned app and then try to run it on the higher-versioned build of the OS. In this case, ApiInformation will succeed because the type exists in the system metadata, but .NET will throw a MissingMethodException at runtime because the type didn't exist in the Union WinMD used to build the app." So you can apparently grab a UWP Library that's supposedly compatible with your app, but it'll crash every time during runtime only on specific versions. We're just finding this out. We've been trying not unnecessarily raise our MinVersion in order to keep users that haven't upgraded yet, and we're trying even harder to avoid having a different TargetVersion than MinVersion precisely because of these compat issues. We don't currently have the testing setup to test every version of Windows automatically, and it appears that there are zero warnings if you use an API that will cause previous versions to crash. But I couldn't figure out, given that we already have an application, is there a way I could set a UWP Library to have a low min version (like 16299) but access polyfilled APIs? |
Beta Was this translation helpful? Give feedback.
-
I should add that we're trying to get viewability information when the app isn't on the main monitor, which apparently has issues on other APIs. So we're using |
Beta Was this translation helpful? Give feedback.
-
The specific problem you cite (new library, old app, new OS) would be solved by moving to .NET Core, since it doesn't rely on compiling against the app's target Union WinMD anymore. The general problem of "old code expects foo, new code expects bar" will continue to be an issue though. It's definitely on our minds though (it's a very hard problem) so thanks for asking. |
Beta Was this translation helpful? Give feedback.
-
I've never been able to figure out from the documentation - how would a Store App move to .NET Core? |
Beta Was this translation helpful? Give feedback.
-
By "Store" I am assuming you mean UWP (it should be relatively easy to build a Packaged Win32 App for the Store). It's not easy to use .NET Core for UWP today, but is technically possible. There are some posts online showing how to do it, but I can't find them right now. Making it easier is something we're working towards with Reunion. |
Beta Was this translation helpful? Give feedback.
-
There's an issue here that details what's required to use .NET 5 (which is the next version of .NET Core due for release in a couple months; not sure if this could be easily adapted to work with .NET Core 3.1 or not) with UWP today, along with the limitations of the approach. |
Beta Was this translation helpful? Give feedback.
-
I've got a UWP that we're trying not to update our target version to the latest because of the massive amount of uncertainty that it causes with using Windows APIs. Visual Studio / Roslyn does not appear to provide any sort of tooling or help with determining if you are using an API that isn't available in an earlier version. Worse than that is issues like this: https://stackoverflow.com/questions/47540577/does-apiinformation-not-respect-the-app-target-version
Where you can have a runtime crash even when doing api checking.
I was hoping that Reunion might be able to help solve this problem! Unfortunately I'm not sure it can - or if it can, how. I don't need WinUI, I don't need MSIX packaging - I'd just like to make a library that's Windows version independent but still using SDKs (hopefully with polyfill) and then use that library in a UWP.
Can Reunion help with this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions