Why can I not use Windows.Media.Capture?

Charles Kinzel 21 Reputation points
2021-11-08T22:31:58.827+00:00

using Windows.Media.Capture;
also tried System.Windows.Media.Capture

"The type or namespace name 'Capture' does not exist in System.Windows.Media"

I am developing in Unity 2020.3.18 with the HoloLens 2 and Visual Studio 2019. I have added reference assemblies PresentationCore and WindowsBase.

HoloLens | Development
HoloLens | Development
The process of creating immersive mixed reality applications for Microsoft HoloLens,
0 comments No comments
{count} votes

Answer accepted by question author
  1. Hernando Ren 2,171 Reputation points
    2021-11-09T07:17:25.82+00:00

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.