Hi fellow MSFT developers,
I have created a sample project for your convenience, available at
https://github.com/JiyaDesai-FandCo/WpfAppdotnet8
We have existing code in Library (of type .NET Standard 2.0) that heavily uses Store APIs, Addon and stuff. and we reuse this library in all our Store App projects. Currently this library is used in WPF (.NET 4.8) and UWP projects and all is running fine.
Problem occurred when we decided to create WPF project with .NET Core 8.0 That's where we are unable to use the library.
Now let me explain the sample project on github, which you can download, explore and help us to identify issue or workaround. The aim is to reuse library in all kind of projects. (WPF with .NET 4.8, UWP and WPF with .NET Core 8.0 ). Keeping in mind we are going to publish it on Store.
Also Note: while you debug, please always run packaging projects only.
ClassLibrarydotnetStandard2 :
- Has reference Microsoft.Windows.SDK.Contracts version 10.0.22621.2428 nuget package
- Has a function that calls Windows.ApplicationModel.Package.Current;
- public string LibraryFunctionToGetPackageName() { ... }
- Assume it has other functions related to Store API
xWpfApp1 : WPF with .NET Framework 4.8
- References ClassLibrarydotnetStandard2
- Calls function : var s = c.LibraryFunctionToGetPackageName();
- (Do not run xWpfApp1 directly, instead run xWpfApp1_Package.)
xWpfApp1_Package : Packaging project for xWpfApp1
- Compile and Run.
- Click on button #1 to call library function
- You should see, it does succeed.
WpfAppdotnet8 : WPF with .NET Core 8.0
- References ClassLibrarydotnetStandard2
- Calls function: this.Title = c.LibraryFunctionToGetPackageName();
- (Same, do not run WpfAppdotnet8 directly, instead run below packaging project.)
WPFdotnet8_PackageToPublishToStore : Packaging project for WpfAppdotnet8
- Compile and Run the package project
- Click on button #1
- You will see Error during library call. Exception: "System.PlatformNotSupportedException"
We want to resolve this error, so that we can use library successfully in WpfAppdotnet8
Hope I was able to explain.
Thanks & Regards
Awaiting your response very curiously.