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:
https://blogs.msdn.microsoft.com/smondal/2012/10/02/unable-to-cast-com-object-of-type-system-__comobject-to-interface-type-microsoft-visualstudio-ole-interop-iserviceprovider/
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.
https://forums.asp.net/
Thanks for your understanding.
Regards,
Judyzh
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.