Hello, Welcome to Microsoft Q&A,
You should wrap around any WinRT-leveraged code in the ENABLE_WINMD_SUPPORT compiler directive to only use certain code when compiling against UWP. For more information please see:Universal Windows Platform: WinRT API in C# scripts
----
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.