locked
Platform::Vector RRS feed

  • Question

  • Hi, has anyone ever tried Platform::Vector and make it work? I was trying to use it in the way as it was addressed in Herb's session 532. But the compiler complains that 'Vector' is not defined even with "Platform" namespace included. Later I found that the "Platform" component is not in the default References list so I tried to browse to the "Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\Platform.winmd" (is this the right one?) and add it, but VS just pops up an error message: "Operation is not valid due to the current state of the object"

    I have tried both VS 11 ultimate and express and they both have the same problem.

    Thanks.

    Thursday, December 29, 2011 2:24 AM

Answers

  • Did you include collection.h in the file from where you are trying to use Platform::Vector?
    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Thursday, December 29, 2011 3:15 AM

All replies

  • Did you include collection.h in the file from where you are trying to use Platform::Vector?
    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    Thursday, December 29, 2011 3:15 AM
  • Hi Raman, thanks for the reply. Below are what I later found on this:

    1) Create a new WinRT application project, and code like Vector<int>^ vec = ref new Vector<int>(); simply works without having to add any namespace or include any headers.

    2) Create a new WinRT component dll project, and the above code can not compile and have to include collections.h as you suggested.

    Is including collections.h an expected way doing the job? Or a problem of VS or something.

    Thursday, December 29, 2011 4:54 AM
  • This is the expected behavior, although we need to document this clearly. The reason you do not need to manually include the header in the Metro style app projects, is due to XAML including the header for you behind the scenes.

     

    Thanks,

    -David 

    Thursday, January 12, 2012 6:33 PM
    Moderator