VS 2017 Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage' RRS feed

  • Question

  • i am making an existing VS 2013 /2015 extension compatible with VS 2017.

    the ASP.NET projects are failing while running the "publish site" task. (it was working fine with the earlier version of VS)

    this is the runtime exception that i am getting :

    ERROR: Publishing website failed. Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage'. This operation failed because the QueryInterface call on the COM component for the interface with IID  failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    on debugging , found that it is failing for the following :

    IVsBuildPropertyStorage buildProps = (IVsBuildPropertyStorage) project;

    where project is of type IVsHierarchy .

    checked both the interfaces .:

    IVsBuildPropertyStorage : from Microsoft.VisualStudio.Shell.Interop.8.0.dll

    IVsHierarchy                  : from Microsoft.VisualStudio.Shell.Interop.dll

    both the dll are added in the reference properly .

    1. Is this a known issue in VS 2017? if yes , how can i resolve it ? 

    2. Is there any other way to get the build properties ? 

    Monday, March 5, 2018 6:42 AM

All replies

  • Hi AS1208,

    Welcome to the MSDN forum.

    According to your description, this issue is probably caused by that it does a direct cast of IVsHierarchy to IVsBuildPropertyStorage. Reference this document, when we attempt to call Single-Threaded Apartment (STA) model COM components from an Multi-Threaded Apartment (MTA) thread, will be encountered this error. As far as I know, ASP.Net is Multi-Threaded project, is your COM object Single-Threaded?

    Please try to set the thread execution type on the main application thread before it is started. Or, spin up a new thread for the job at hand, and set the thread execution state on the new thread before executing it.

    If above method not help you, this blog describes the similar error message with you, you could have a look at it:


    In addition, this forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. Your issue related to asp.net development, if you want to know more information about asp.net development, I suggest you visit following forum to get a professional answer.


    Thanks for your understanding.




    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    • Edited by Judy ZhuY Tuesday, March 6, 2018 3:24 AM
    • Proposed as answer by Judy ZhuY Wednesday, March 7, 2018 8:59 AM
    Tuesday, March 6, 2018 3:23 AM