如何使我的 GUID 对 VSTO 外接程序可见
我尝试将以下代码添加到我的加载项代码的开头:
Namespace NS
[Guid("211B3945-E2AE-48DD-8A9A-77ADB40EC6D5")]
[ComVisible(true)]
public partial class Classname
{
但是当我列出 COMAddins 时它不会出现(名称会出现,但 GUID 不会出现)。
我还尝试在程序集信息下的编译设置中设置它,但没有成功。
顺便说一句 - 我试图解决的问题是查看 COM 插件是否通过搜索其 GUID 来加载。当我检查 ComAddIn 列表时,会显示 Addin 描述,但无论我如何遵循这些说明,GUID 仍然显示零。我试图使用以下代码查看可见内容:
olApp = this.Application;
Office.COMAddIns CAIs = olApp.COMAddIns;
foreach (Office.COMAddIn CAI in CAIs)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(CAI.Description);
sb.AppendLine(CAI.Guid);
sb.AppendLine("****");
Debug.Print(sb.ToString());
}
I've tried adding the following code to the beginning of my add-in code as such:
Namespace NS
[Guid("211B3945-E2AE-48DD-8A9A-77ADB40EC6D5")]
[ComVisible(true)]
public partial class Classname
{
but it doesn't appear when I list the COMAddins (the name does, but not the GUID).
I've also tried setting it in my compile settings under Assembly information with no luck.
BTW - the issue I'm trying to resolve is seeing if a COM Addin is loaded by searching for its GUID. The Addin description shows up when I check the list of ComAddIns, but the GUID still shows zeroes no matter how I follow these directions. I'm trying to see what's visible by using the following code:
olApp = this.Application;
Office.COMAddIns CAIs = olApp.COMAddIns;
foreach (Office.COMAddIn CAI in CAIs)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(CAI.Description);
sb.AppendLine(CAI.Guid);
sb.AppendLine("****");
Debug.Print(sb.ToString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里缺少一些公开 COM 的内容,包括重写
RequestComAddInAutomationService
和设置[InterfaceType(ComInterfaceType.InterfaceIsDual)]
请参阅以下项目:
There are a number of things missing here to expose COM, including overriding
RequestComAddInAutomationService
and setting[InterfaceType(ComInterfaceType.InterfaceIsDual)]
See the following items: