Visual Studio 2017中的System.invalidcastexception错误 [英] System.invalidcastexception error in Visual Studio 2017
问题描述
看到错误:无法将"System .__ ComObject"类型的COM对象强制转换为接口类型"Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage"。此操作失败,因为对于具有IID
'{E7355FDF-A118-48F5-9655-7EFD9D2DC352}的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT异常:0x80004002 (E_NOINTERFACE))在下面的代码中:
Am seeing error: 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 '{E7355FDF-A118-48F5-9655-7EFD9D2DC352}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)) in below code:
IVsBuildPropertyStorage buildProps =(IVsBuildPropertyStorage)项目,其中项目类型为IVsHierarchy。
IVsBuildPropertyStorage buildProps = (IVsBuildPropertyStorage)project where project is of type IVsHierarchy.
这类似于此处提到的代码库: https://docs.microsoft.com/en-us/visualstudio/extensibility/adding-an-attribute-to-a-project-item。但是我们仍然在Visual Studio 2017中看到错误。相同的代码工作文件直到Visual Studio 2015.
This is similar to code base as mentioned here: https://docs.microsoft.com/en-us/visualstudio/extensibility/adding-an-attribute-to-a-project-item. However we still see the error in Visual Studio 2017. The same code works file till Visual Studio 2015.
任何指针都会有所帮助。
Any pointers would be helpful.
Vinita
推荐答案
Hi Vinita Sang
根据您的描述,我使用视觉工作室企业2017创建了一个简单的命令菜单 示例和您的代码,并在我身边重现您的问题,但是我使用你提供的链接代码,它运行良好。
According to your description, I create a simple command menu sample with your code by using visual studio Enterprise 2017 and reproduce your issue on my side, but I use the code with the link that you provide, it works well.
致以最诚挚的问候,
张龙
这篇关于Visual Studio 2017中的System.invalidcastexception错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!