locked
Iterating Project.ConfigurationManager.SupportedPlatforms in JScript RRS feed

  • Question

  • In a Custom AppWizard running under Visual Studio 2005, I need to see if a particular platform (x64) appears in the list Project.ConfigurationManager.SupportedPlatforms, in order to decide whether or not to add a new platform to the project. The property shows up in the debugger as an array of VARIANTs.

    I have tried all the following to look at its values:

    for (var p in proj.ConfigurationManager.SupportedPlatforms) { ... }
    for (var e = new Enumerator(proj.ConfigurationManager.SupportedPlatforms); !e.atEnd(); e.moveNext()) { ... }
    for (i = 0; i < proj.ConfigurationManager.SupportedPlatforms.Count; i++) { ... }

    and even:

      var i = 0;
      var strThis;
      while (true) {
        try {
          strThis = proj.ConfigurationManager.SupportedPlatforms[i];
        }
        catch(e) {
          return false;  // Out of range
        }
        ...
        i++;
      }
    

    None of these methods works. Does anyone know how to look at this list in JScript under VS2005? I imagine I'm missing the obvious here...

    Thanks

    Bruce

     

     

    Wednesday, June 1, 2011 8:21 PM

Answers

  • Hi Victor,

    Thank you for your reply. I found a solution by using the JScript VBArray object, which is able to inspect the SAFEARRAY returned by ConfigurationManager.SupportedPlatforms.

    For those who encounter a similar problem, here is the JScript that worked:

    function IsPlatformSupported(proj, strPlatformName) {
      var strCmp = strPlatformName.toLowerCase();
      var i;
      var strThis;
      
      var theArray = new VBArray(proj.ConfigurationManager.SupportedPlatforms);
      for (i = theArray.lbound(); i <= theArray.ubound(); i++) {
        strThis = theArray.getItem(i);
        if (strThis.toLowerCase() == strCmp) {
          return true;
        }
      }
      return false;
    }
    
    
    
    
    • Marked as answer by fnqbruce Friday, June 3, 2011 1:44 AM
    Friday, June 3, 2011 1:44 AM

All replies

  • Hi Bruce,

     

    Thanks for your post.

    As far as I know, proj.ConfigurationManager.SupportedPlatforms returns an array of string,

    if you can get the correct value in JS, I believe your for loop syntax is correct as well.

    For testing, you can try to print out the current active configuration, proj.ConfigurationManager.ActiveConfiguration,

    Let me know the result.

     


    Ziwei Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 2, 2011 7:50 AM
  • Hi Victor,

    Thank you for your reply. I found a solution by using the JScript VBArray object, which is able to inspect the SAFEARRAY returned by ConfigurationManager.SupportedPlatforms.

    For those who encounter a similar problem, here is the JScript that worked:

    function IsPlatformSupported(proj, strPlatformName) {
      var strCmp = strPlatformName.toLowerCase();
      var i;
      var strThis;
      
      var theArray = new VBArray(proj.ConfigurationManager.SupportedPlatforms);
      for (i = theArray.lbound(); i <= theArray.ubound(); i++) {
        strThis = theArray.getItem(i);
        if (strThis.toLowerCase() == strCmp) {
          return true;
        }
      }
      return false;
    }
    
    
    
    
    • Marked as answer by fnqbruce Friday, June 3, 2011 1:44 AM
    Friday, June 3, 2011 1:44 AM