C#如何安装Windows.Media.Transcoding

C# how to install Windows.Media.Transcoding

在我当前的项目中,我需要使用 Windows 媒体转码 API。但是,我无法安装它。

在这里你可以看到我使用了正确的命名空间。

using System.Windows.Media.Transcoding;

我在 NuGet 上四处寻找,但在那里找不到它。我阅读了有关它的 Microsoft 页面,但那只告诉了我名称空间。我也找不到它的大会。有人可以帮我安装吗

您可以按照以下说明操作:

通过使用外部编辑器打开 .csproj 文件并添加行

来修改目标平台
<TargetPlatformVersion>8.0</TargetPlatformVersion>

这个例子

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{6D41F51D-5A85-4826-9868-14FB3591F280}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>WindowsFormsApplication1</RootNamespace>
    <AssemblyName>UseWindowsMediaTranscodingAPI</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>

重新加载解决方案并添加对 Windows Core Media DLL 的引用

这应该已经编译。

此外,为了能够处理事件和异步方法映射,您应该添加对系统 dll 的引用:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.InteropServices.WindowsRuntime

请记住,该应用程序只能在 Windows 10.

上运行

来源:https://blogs.msdn.microsoft.com/cdndevs/2013/10/02/using-windows-8-winrt-apis-in-net-desktop-applications/