简体   繁体   English

VS2012错误C1107

[英]VS2012 Error C1107

I am getting the following error: 我收到以下错误:

fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable

Steps to reproduce 重现步骤

0) Create a new empty project 0)创建一个新的空项目

1) C/C++ > General > Consume Windows Runtime Extension > YES 1)C / C ++>常规>使用Windows运行时扩展>是

2) C/C++ > Code Generation > Enable Minimal Rebuild > No 2)C / C ++>代码生成>启用最小重建>否

3) Add a source file *.cpp, file can be blank 3)添加源文件* .cpp,文件可以为空

4) Attempt to compile 4)尝试编译

I tried to manually compare and change the project settings to match that in some sample code but nothing seems to work. 我试图手动比较和更改项目设置,以匹配一些示例代码,但似乎没有任何工作。

I don't understand what the problem you have, so 我不明白你有什么问题,所以

  1. If you don't want to code against WinRT just set "Consume..." to false and the issue will be gone 如果您不想针对WinRT进行编码,只需将“Consume ...”设置为false,问题就会消失
  2. If you want to code against WinRT you should perform an additional step: go to General and set Windows Store App Support to true 如果要对WinRT进行编码,则应执行其他步骤:转到“ 常规”并将“ Windows应用商店应用支持”设置为true

To create a C++/CX Desktop application: 要创建C ++ / CX Desktop应用程序:

In C/C++ -> General project properties, set Consume Windows Runtime Extension to Yes C/C++ -> General项目属性中,将“使用Consume Windows Runtime Extension设置为“是”

In the same tab enter these to your Additional #using Directories enter the directories containing the windows.winmd and platform.winmd files. 在同一个选项卡中,将这些输入到您的Additional #using Directories输入包含windows.winmdplatform.winmd文件的目录。 For me, with VS2017, that is: 对我来说,使用VS2017,即:

C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\store\\references; C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ VC \\ lib \\ store \\ references;
C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata; C:\\ Program Files(x86)\\ Windows Kits \\ 10 \\ UnionMetadata;
C:\\Program Files (x86)\\Windows Kits\\10\\References\\Windows.Foundation.UniversalApiContract\\2.0.0.0; C:\\ Program Files(x86)\\ Windows Kits \\ 10 \\ References \\ Windows.Foundation.UniversalApiContract \\ 2.0.0.0;
C:\\Program Files (x86)\\Windows Kits\\10\\References\\Windows.Foundation.FoundationContract\\2.0.0.0 C:\\ Program Files(x86)\\ Windows Kits \\ 10 \\ References \\ Windows.Foundation.FoundationContract \\ 2.0.0.0

Then call RoInitialize or use a WinRT main style function (to remove the warning C4447 about main threading): 然后调用RoInitialize或使用WinRT主样式函数(删除关于主线程的警告C4447):

using namespace Platform;

int main(Array<String^>^ args) ....

References: 参考文献:
Using C++/CX in Desktop apps , 在桌面应用程序中使用C ++ / CX
Calling Windows 10 APIs from a desktop application 从桌面应用程序调用Windows 10 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM