使VSIX软件包自动化对象com可见withou手动recasm重新恢复
我正在处理一个可以提供自动化对象的Visual Studio软件包,后来可以通过COM和DTE.GetObject(字符串名称)调用在第三方应用程序中使用。
为此,我创建了以下设置。 在Visual Studio实例中,我有以下VSIX软件包运行。
namespace CustomAutomationObjectProvider
{
[Guid("5B152019-535C-4602-9084-3F5250118A7D")]
public interface ICustomAutomationObject
{
string GetCustomString();
}
[ComVisible(true)]
public class CustomAutomationObject : ICustomAutomationObject
{
public string GetCustomString()
{
return "Hello from automation object!";
}
}
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid("61C27A04-A031-4DF6-8E48-0B4BFEB8F49B")]
[ProvideAutomationObject("CustomAutomationObject")]
public sealed class AutomationObjectProvider : AsyncPackage
{
private CustomAutomationObject _instance;
protected override object GetAutomationObject(string name)
{
if(name == "CustomAutomationObject")
{
if(_instance == null)
{
_instance = new CustomAutomationObject();
}
}
return _instance;
}
}
}
在第三方应用程序中,我要连接到Visual Studio的实例,获取其DTE对象,并尝试获取这样的自动化对象。我能够从getObject调用中获取一些对象,但是我无法将其施放到目标界面 - 它在E_NOInterface失败了,
[STAThread]
public static void Main(String[] args)
{
...
...
var customAutomationObjectRaw = DTE.GetObject("CustomAutomationObject");
var customAutomationObject = (CustomAutomationObjectProvider.ICustomAutomationObject)customAutomationObjectRaw;
}
我想我可能会错过解决方案或VSIX软件包配置中的一些COM可见度设置查找有关它的任何信息。我可以在RegasM.exe中注册汇编手册,但基于此线程
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论