R
Ramesh
Hello,
I have a COM addin developed in C#, which is loaded into PowerPoint.
This addin has a method void OnTest(). I need to access this function
from another app developed in C#. This is what I'm doing:
PowerPoint.Application app = new PowerPoint.Application();
app.Visible = Office.MsoTriState.msoTrue;
app.Presentations.Add( Office.MsoTriState.msoTrue );
object addInName = "MyTestAddin.Connect";
Office.COMAddIn addIn = app.COMAddIns.Item( ref addInName );
Type addInType = Type.GetTypeFromProgID( addIn.ProgId );
addInType.InvokeMember( "OnTest",
BindingFlags.Public | BindingFlags.InvokeMethod,
null,
addIn, // Or addIn.Object
null // Or new object[] {}
);
At this point, it throws a "Object does not match target" exception.
The addIn.Object is the right one; I confirmed it through
addIn.ProgId() call. Obviously I'm doing something wrong, but I can't
figure out what. Any help in this regard would greatly help. BTW, I'm
trying this on PP2000 and Win XP Pro SP2, with C# 2003, and this needs
to work on PP XP and PP2003 as well.
Or should I use some other method? I'm pretty new to C# and .NET, so
I'd be very thankful to anyone who could help me out.
Thanks a lot in advance,
Ramesh
I have a COM addin developed in C#, which is loaded into PowerPoint.
This addin has a method void OnTest(). I need to access this function
from another app developed in C#. This is what I'm doing:
PowerPoint.Application app = new PowerPoint.Application();
app.Visible = Office.MsoTriState.msoTrue;
app.Presentations.Add( Office.MsoTriState.msoTrue );
object addInName = "MyTestAddin.Connect";
Office.COMAddIn addIn = app.COMAddIns.Item( ref addInName );
Type addInType = Type.GetTypeFromProgID( addIn.ProgId );
addInType.InvokeMember( "OnTest",
BindingFlags.Public | BindingFlags.InvokeMethod,
null,
addIn, // Or addIn.Object
null // Or new object[] {}
);
At this point, it throws a "Object does not match target" exception.
The addIn.Object is the right one; I confirmed it through
addIn.ProgId() call. Obviously I'm doing something wrong, but I can't
figure out what. Any help in this regard would greatly help. BTW, I'm
trying this on PP2000 and Win XP Pro SP2, with C# 2003, and this needs
to work on PP XP and PP2003 as well.
Or should I use some other method? I'm pretty new to C# and .NET, so
I'd be very thankful to anyone who could help me out.
Thanks a lot in advance,
Ramesh