简体   繁体   中英

How do I make my GUID visible for a VSTO Add-in

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());
}

There are a number of things missing here to expose COM, including overriding RequestComAddInAutomationService and setting [InterfaceType(ComInterfaceType.InterfaceIsDual)]

See the following items:

  1. VSTO Add-ins, COMAddIns and RequestComAddInAutomationService
  2. VSTO in VBA: AddIn.Object returns Nothing (null) sometimes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM