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(CA开发者_运维技巧I.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:
- VSTO Add-ins, COMAddIns and RequestComAddInAutomationService
- VSTO in VBA: AddIn.Object returns Nothing (null) sometimes
精彩评论