none
为何在DLL项目的源代码中,Platform命名空间无效? RRS feed

  • 问题

  • 在一个Windows Universal store apps应用中,添加了一个DLL(Universal apps)项目,但在DLL项目的程序代码中,使用using namespace Platform;时,命名空间Platform无效,应该如何解决?
    2014年11月10日 13:54

答案

  • 你好:

         命名空间Platform是不能用在C++的dll的,也没有项目属性可以修改。MS建议的是使用Component Extensions (C++/CX ) , 请参考该样例程序的说明部分: https://code.msdn.microsoft.com/windowsapps/media-extensions-sample-7b466096

    "In most situations, it is recommended that you use Visual C++ with Component Extensions (C++/CX ) to interact with the Windows Runtime. But in the case of hybrid components that implement both COM and Windows Runtime interfaces, such as Media Extensions, this is not possible. C++/CX can only create Windows Runtime objects. So, for hybrid objects it is recommended that you use Windows Runtime C++ Template Library to interact with the Windows Runtime. Be aware that Windows Runtime C++ Template Library has limited support for implementing COM interfaces."

    Shu Hu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    2014年11月12日 2:09

全部回复

  • 你好 不靠谱,

    DLL项目是C++的还是C#的?Platform貌似是C++专用的,http://msdn.microsoft.com/en-us/library/hh710417.aspx 应该不能用在C#项目中。

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    2014年11月11日 1:43
    版主
  • 你好,我是先建立了一个c++的windows store apps(Universal apps)项目,然后在这个项目所在的方案中,又添加了一个c++的DLL(Universal apps)项目,但在DLL项目中的程序代码中,使用用using namespace Platform,其中的Platform下出现红色折线标识其为无效的空间名字。谢谢!
    2014年11月11日 2:15
  • 其实,我是模仿样例程序MediaExtensions,这个样例程序也是用DLL,其中的代码中就有using namespace Platform,可为何我这样用就不行呢?是不是存在项目属性设置上的问题?
    2014年11月11日 3:31
  • 你好:

         命名空间Platform是不能用在C++的dll的,也没有项目属性可以修改。MS建议的是使用Component Extensions (C++/CX ) , 请参考该样例程序的说明部分: https://code.msdn.microsoft.com/windowsapps/media-extensions-sample-7b466096

    "In most situations, it is recommended that you use Visual C++ with Component Extensions (C++/CX ) to interact with the Windows Runtime. But in the case of hybrid components that implement both COM and Windows Runtime interfaces, such as Media Extensions, this is not possible. C++/CX can only create Windows Runtime objects. So, for hybrid objects it is recommended that you use Windows Runtime C++ Template Library to interact with the Windows Runtime. Be aware that Windows Runtime C++ Template Library has limited support for implementing COM interfaces."

    Shu Hu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    2014年11月12日 2:09
  • 非常感谢!明白了!!!
    2014年11月12日 3:13