我已经编写了一个小的 Media Foundation Transform ,并将C ++ DLL添加到我的C# Windows应用商店应用项目中。
运行x86配置的DLL的32位版本工作正常,但x64不起作用(它抛出异常,并显示以下消息:
“MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED:HRESULT - 0x800700C1”)
如果我添加64位版本,它只是相反的方式围绕x64工作而x86没有。
我有什么方法可以设置它,以便它使用x86版本的DLL用于x86配置,而x64版本用于x64配置?
答案 0 :(得分:0)
花了我一些时间,但我想出了如何使用NuGet做到这一点。 首先,我在我的PC上添加了一个位置作为包源,如here所述。
在VS2013 CE中,您可以通过打开NuGet程序包管理器设置(工具> NuGet程序包管理器>程序包管理器设置)来执行此操作,并在程序包源下在计算机上添加位置。
为了创建NuGet,我结合了几个HowTo,因为一个人没有工作。 主要的是this。
我为所需的平台构建了dll并创建了以下文件夹结构
因为可能有点难以看到ProjectName.props和ProjectName.targets位于netcore451文件夹中。 lib中的.dll,.pri和.winmd是x86版本。根据HowTo它是多余的,您可以忽略这些文件但没有它们VS可能无法在设计模式下正常工作。
在包含build和lib的文件夹中,我创建了一个文件ProjectName.nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>ProjectName</id>
<version>1.0.0</version>
<authors>Stefan Fabian</authors>
<owners>Stefan Fabian</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<releaseNotes>First release.</releaseNotes>
<copyright>Copyright 2015</copyright>
<references>
<group targetFramework=".NETCore4.5.1">
<reference file="ProjectName.winmd" />
</group>
</references>
</metadata>
</package>
ProjectName.props
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
ProjectName.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PlatformCheck" BeforeTargets="InjectReference"
Condition=" ( ('$(Platform)' != 'x86') AND ('$(Platform)' != 'AMD64') AND ('$(Platform)' != 'Win32') AND ('$(Platform)' != 'ARM') AND ('$(Platform)' != 'x64') )">
<Error Text="$(MSBuildThisFileName) does not work correctly on '$(Platform)'
platform. You need to specify platform (x86 / x64 or ARM)." />
</Target>
<Target Name="InjectReference" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup Condition="'$(Platform)' == 'x86' or '$(Platform)' == 'Win32'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)x86\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'AMD64'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)x64\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'ARM'">
<Reference Include="ProjectName">
<HintPath>$(MSBuildThisFileDirectory)ARM\ProjectName.winmd</HintPath>
</Reference>
</ItemGroup>
</Target>
</Project>
我不确定是否有必要检查x86和Win32,但它对我有用。
<强>声明强>
这是我第一次创建NuGet包,上面的代码可能很糟糕。