View Single Post
  #3  
Old January 12th 09, 02:14 PM posted to microsoft.public.outlook.program_addins
Nenad
external usenet poster
 
Posts: 11
Default Reference to AddIn

I can get a reference to Office.COMAddIn, but what I really need is a
reference to TheAddIn (which is a subclass of a Microsoft.Office.Tools.AddIn
class and is inherited from
Microsoft.VisualStudio.Tools.Applications.Runtime. IStartup interface).

This is code from Initialize(Outlook.Application app) method from user
control hosted in FHP:

object name = "MyAddIn";
Office.COMAddIn addin = (Office.COMAddIn)app.COMAddIns.Item(ref
name);
ThisAddIn add = addin.Object as AddIn.ThisAddIn;

I was hoping that I will get a reference to VSTO AddIn using addin.Object
property, but it is always null. I also tried to set that property in the
start-up event of the add-in, but it caused TypeMismatch error, so I assume
that it is a misleading.

Anyway, I have set [ComVisible(true)] attribute on the add-in, but it didn't
helped.

Thanks for templates, they are great, but I didn't find what I needed there.

Thanks

"Ken Slovak - [MVP - Outlook]" wrote:

You need to make the addin COM visible and then depending on whether or not
it's a VSTO addin make public a reference to the addin if you want to call
on methods or properties of the addin.

I don't have anything for VS 2008, but I do have C# templates for VS 2005
for both shared addins and VSTO 2005SE addins that shows how to expose your
addin and methods/properties in it to outside code. You can find them at
http://www.slovaktech.com/outlook_2007_templates.htm. The templates are all
Outlook 2007 specific.

To just reference the addin as an Office.COMAddIn you would use code
something like this assuming olApp is your Outlook.Application object
reference:

Office.COMAddIn addin = olApp.COMAddIns.Item("MyAddinName");

If your addin is shared and uses a Connect class that would look like this:
"MyAddinName.Connect".

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Nenad" wrote in message
...
I am programming Outlook 2003 AddIn using Visual Studio 2008 and C#.

I need to pass a reference to AddIn to user control embedded in Folder
Home
Page, but it is always a null. I already found out that it's a security
barrier which prevents passing a reference.

Did anyone knows any other way to pass a reference to C# AddIn?

Thanks, Nenad



Ads