Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / October 2004

Tip: Looking for answers? Try searching our database.

Add-in stops getting notifications

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Schwartz - 17 Dec 2003 07:37 GMT
I wrote a C# COM add-in based on the sample from MSDN.
In OnConnection() I sign up for the
applicationObject.Inspectors.NewInspector event using the
following code:
applicationObject.Inspectors.NewInspector +=
   new Outlook.InspectorsEvents_NewInspectorEventHandler
       (NewInspectorMethod);

At some point I stop getting this notification.
To be more specific, when I open a new meeting request, I
add some buttons to the command bar, and when I open one
of my forms, by pressing these buttons, I stop getting
the NewInspector event.
I've checked that I don't have any unhandled exceptions
in my code, so I don't think that my code caused the add-
in to unload.

Is this a known issue? if so, is there anything I can do
to solve it?
Dmitry Streblechenko - 17 Dec 2003 15:15 GMT
Try to store applicationObject.Inspectors as a class variable and set up the
events as:

m_inspectors = applicationObject.Inspectors;
m_inspectors .NewInspector +=  new
Outlook.InspectorsEvents_NewInspectorEventHandler(NewInspectorMethod);

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> I wrote a C# COM add-in based on the sample from MSDN.
> In OnConnection() I sign up for the
[quoted text clipped - 15 lines]
> Is this a known issue? if so, is there anything I can do
> to solve it?
Florin Balanescu - 29 Oct 2004 14:19 GMT
To all of you who have bad experiences with Outlook COM Add-ins written in C#, few adivces:
- GarbageCollector trashes your dispatchers (aka eventHandlers - they represent more, but we stick to the basiscs) so keep fields in your addin as references to both event issuer object and eventHandler object as long as needed. If you don't do this, most of the times you'll end up asking yourself why Outlook doesn't fire events such as itemAdd (from  Folder.Items collection) or why newInspector (from Application.Inspectors collection) doesn't fire all the times.
- If you want to make transparent icons in Office 2000 (including Outlook 2000) watch out this sniplet:
     Bitmap bmpRes= do what you have to do to get a 16x16 bitmap as the icon, with the top-right corner pixel as the transparent color of the icon;
    bmpRes.MakeTransparent(bmpRes.GetPixel(0, 0));
    if (bmpRes != null)
    {
        Bitmap bmpNew= new Bitmap(16, 16);
        Graphics g = Graphics.FromImage(bmpNew);
        g.FillRectangle(new SolidBrush(SystemColors.Control), 0, 0, 16, 16);
        g.DrawImage(bmpRes, 0, 0);
        Clipboard.SetDataObject(bmpNew);
        btn.FaceId = 0;
        btn.PasteFace();
    }
There is a hard way to deal with this, but both examples use Windows API calls (a VB and a C++ version) which are somewhat not recomanded directly in .NET platform (it can be done though, if you realy want to)
For OfficeXP and 2003, you will use Picture and Mask properties, no problem there.
- All the collections have a 1 based index, so getting the first item in a items collection would be items.item(1)

Thank to Dmitry Streblechenko and Ken Slovak. They have both been helpful to me these days.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.