Office Addins General Question

K

KalliMan

Hi all,
I’m trying to write a simple Office Addin using VS2005 (C#) and Shared Addin
Wizard(not VSTO). And everything looks OK, I am able to start and debug my
Addin. But the funs start here. I’ve added references both to EnvDTE and
EnvDTE80, but if I try to cast the “application†parameter (passed in
OnConnection method) to DTE(2) I receive an exception:
System.InvalidCastException: Unable to cast COM object of type
'System.__ComObject' to interface type 'EnvDTE.DTE'.
However in MSDN is written that the “application†parameter is DTE(2). What
I’m wrong? Should I leave this approach to create an Addin and use VSTO?

Thanks and Regards:
KalliMan
 
S

Simon Murphy

KalliMan
You should cast the app parameter to the Office app you are connecting
to. you would use envdte if targetting VS itself
You don't need to revert to VSTO, plain .net works fine for COM Add-ins.
Make sure you shim your add-in if it goes into production.

Cheers
Simon
Blog: www.smurfonspreadsheets.net
 
K

KalliMan

Hi Simon,

Thank you. This is the answer. I should use Microsoft Outlook Object Library.

One more question. If the Addin is written with Outlook 2003 Object Library,
will this Addin work on Outlook 2007?

Best Regards
KalliMan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top