locked
MPF2012 Project Property Page Fails To Load RRS feed

  • Question

  • Hi All,

    I have a package that I have developed that has a number of features including the ability to right click a loaded project and click properties to bring up a custom set of MPF (project) property pages. Or at least, I did have in VS2010 and it's version of the MPF, but now I have moved over to 2012 it has stopped working.

    So I went back a step and looked at the NestedProject sample and have found that when I choose to display it's properties, the exact same error is stopping the pages from loading. The second line below in ProjectDesignerDocumentManager.cs is generating an InvalidCastException:

    IVsUIHierarchyparentHierarchy = this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchy) asIVsUIHierarchy;

    uintparentHierarchyItemId = (uint)this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid);

    Specifically, the error is E_NOINTERFACE but since I don't seem to be able to debug into the cast to uint, I can't even find out what interface is being requested.

    The problem happens in the sample and in my code at exactly the same place, and the exception causes the loading of the properties page to be aborted.

    As I said, it used to work in VS2010 but I don't have that installed anymore to do a comparison. Does anyone have any ideas? It's been driving me nuts for quite a while now.

    Thanks in advance, Loz.


    LozCool

    Tuesday, April 30, 2013 11:15 AM

Answers

  • I had that issue when I merged the MPF 2012 project changes into my package project.  As far as I can tell the property in question is always returned as a signed integer so I'm not sure why the breaking change was introduced in the 2012 version.  I changed it back to casting to an int to match the MPF 2010 project and it started working again.

    Eric

    • Proposed as answer by EWoodruff Tuesday, April 30, 2013 2:59 PM
    • Marked as answer by LozzyLoo Tuesday, April 30, 2013 6:11 PM
    Tuesday, April 30, 2013 2:59 PM

All replies

  • I had that issue when I merged the MPF 2012 project changes into my package project.  As far as I can tell the property in question is always returned as a signed integer so I'm not sure why the breaking change was introduced in the 2012 version.  I changed it back to casting to an int to match the MPF 2010 project and it started working again.

    Eric

    • Proposed as answer by EWoodruff Tuesday, April 30, 2013 2:59 PM
    • Marked as answer by LozzyLoo Tuesday, April 30, 2013 6:11 PM
    Tuesday, April 30, 2013 2:59 PM
  • Eric, you are my saviour!!!!

    If you change the code to the following, everything works as it should (like in the 2010 version):

    int parentHierarchyItemId = (int) this.Node.ProjectMgr.GetProperty((int)__VSHPROPID.VSHPROPID_ParentHierarchyItemid);

    ErrorHandler.ThrowOnFailure(uiShellOpenDocument.OpenSpecificEditor(editorFlags, fullPath, refeditorType, physicalView, reflogicalView, caption, parentHierarchy, (uint) parentHierarchyItemId, docDataExisting, serviceProvider, outframe));

    This is ridiculous for such a change to have been made. What makes it worse is that I tried to correct the problem in the same way as you did already, but using IntPtr and id did not work. IntPtr was used in the 2008 SDK, but fails now!!

    Dear Microsoft.... please don't cast things left right and centre. Grow up and get some consistency in your code at last! Either it's an int, uint or IntPtr but since your are messing with COM from a managed framework, even your documentation suggests IntPtr! Perhaps some internal programming education is due, in this case?

    Meanwhile Eric, THANKS A LOT for your help. I will log a bug report about this in the morning.

    Loz.

     


    LozCool

    Tuesday, April 30, 2013 6:10 PM
  • Just hit this too - I wonder why it is the case that I have to change the MPF to get it to work like this - I can't help feeling that I have missed something!!!

    Surely MS haven't simply released code that doesn't work in such a blatant way?

    Well, thanks for the suggested fix - it works for me too (for now at least!!!)

    Monday, August 4, 2014 3:56 PM