VS 2017无法将“System .__ ComObject”类型的COM对象强制转换为接口类型“Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage” [英] VS 2017 Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage'

查看:163
本文介绍了VS 2017无法将“System .__ ComObject”类型的COM对象强制转换为接口类型“Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作与VS 2017兼容的现有VS 2013/2015扩展程序。

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

运行"发布网站"时,ASP.NET项目失败了。任务。 (它与VS的早期版本一起工作正常)

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 :

错误:发布网站失败。无法将"System .__ ComObject"类型的COM对象强制转换为接口类型"Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage"。此操作失败,因为QueryInterface调用COM组件为
接口与IID 由于以下错误而失败:没有支持这样的接口(来自HRESULT的异常:0x80004002(E_NOINTERFACE))。

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)项目;

IVsBuildPropertyStorage buildProps = (IVsBuildPropertyStorage) project;

其中project是类型  IVsHierarchy。

where project is of type IVsHierarchy .

检查了两个接口。:

IVsBuildPropertyStorage:来自Microsoft。 VisualStudio.Shell.Interop.8.0.dll

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

IVsHierarchy                  :来自  Microsoft.VisualStudio.Shell.Interop.dll

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

这两个dll都在参考中正确添加。

both the dll are added in the reference properly .

1。这是VS 2017中的一个已知问题吗?如果是,我该如何解决? 

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

2。有没有其他方法可以获得构建属性? 

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

推荐答案


嗨AS1208,

欢迎来到MSDN论坛。

< span style ="margin:0px; color:#666666; line-height:107%; font-family:'Segoe UI',sans-serif; font-size:10pt">根据你的描述,这个问题可能是由于通过它,它将IVsHierarchy直接转换为IVsBuildPropertyStorage。
参考
文档,当我们尝试从多线程单元(MTA)线程调用单线程单元(STA)模型COM组件时,将遇到此错误。据我所知,ASP.Net是多线程项目,
是你的COM对象单线程?

请尝试设置线程执行类型在主应用程序线程启动之前。或者,为手头的作业启动一个新的线程
,并在执行它之前在新线程上设置线程执行状态。

如果以上方法没有帮助你,这个博客描述了类似的错误信息,你可以看看它:

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 /

https://forums.asp.net/  

感谢您的理解。

问候,

Judyzh

 

注意:此响应包含对第三方万维网站点的引用。为方便起见,Microsoft提供此信息

Microsoft不控制这些网站,也没有测试在这些网站上找到的任何软件或信息;

因此,Microsoft不能就任何软件的质量,安全性或适用性或在那里找到的
信息做出任何陈述。





这篇关于VS 2017无法将“System .__ ComObject”类型的COM对象强制转换为接口类型“Microsoft.VisualStudio.Shell.Interop.IVsBuildPropertyStorage”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆