假设我的WinRT Component编译后的文件为CppLib.dll 和CppLib.winmd
那么在用VS2012编写的JS程序可以直接调用WinRT COmponent,如下:
var nativeObject = new CppLib.Class1();
但是我新建一个Metro Store风格的程序Blank APP(XAML)如何调用该WinRT Component程序呢?
Oh, I see.
找寻如何在C++里面使用WinRT Component花费了不少时间。
C++里面命名空间引用方式为 “::”
而JS里面命名空间的引用方式为”."
所以在C++里面需要CppLib::Class1 ^ pHello = ref new CppLib::Class1()来创建新类。
而在JS里面只要CppLib.Class1^ pHello = ref new CppLib.Class1();
根据之前的帖子:http://social.msdn.microsoft.com/Forums/zh-CN/metroappzhcn/thread/52e5cbde-bd7a-41f4-a3e0-41400c1ae3dc/
我已经按照上述帖子添加了,如下:
using namespace CppLib;
auto pHello = ref new CppLib.Class1();
可是还出现错误:error C2061: syntax error : identifier 'CppLib'
请大家看看是什么问题呢??