AddAdvise exception with error code 0x86db0898

S

Scott A. Guyer

Hi Folks,

I've create a Windows Forms app in vs.net 2003 and added the Visio
11 activex control to my application. So far so good. However, in an
attempt to trap connection add and delete events in my app I added
the following code to my app's constructor (following the
InitializeComponent() call).

visioApp.EventList.AddAdvise( (short)System.Convert.ToInt16(
Microsoft.Office.Interop.Visio.VisEventCodes.visEvtConnect),
new MyEventSink(), "", "Added connections handler" );

Note that MyEventSink is a class that implements IVisEventProc.

The problem is, at runtime, I get a useful exception
"\n\nAn exception occurred."
Digging in debugger it looks like this is a result error code
0x86db0898. Unfortunately, I can't garner anything from this code.
Nothing in my web searches, MSDN search, vs.net error lookup, etc.

Anyone have any ideas? Has anyone had success with using AddAdvise
in C# with the Visio 2003 SDK? Recommended alternative approach?

Thank you,
-Scott
 
M

Markus Breugst

Hello Scott,

I guess your event code is not correct. Please try these ones:
public const short ConnectionAdded = (short) -32768 + (short)
VisEventCodes.visEvtConnect;
public const short ConnectionRemoved = (short) VisEventCodes.visEvtDel +
(short) VisEventCodes.visEvtConnect;

By the way: You can find a table with all event codes in the MSDN library
(SDK documentation -> Events -> Event codes).


Best regards,
Markus
 
B

Bill K. [MSFT]

Try adding a member variable to your class so the MyEventSink object does
not go out of scope and get garbage collected (aka "deleted").

Declare a variable in your Windows Forms class:
private eventSink MyEventSink = null;

In the constructor, create an instance of the event sink before calling
AddAdvise:
eventSink = new EventSink();

Pass a reference to the event sink to the AddAdvise method
visioApp.EventList.AddAdvise( (short)System.Convert.ToInt16(
Microsoft.Office.Interop.Visio.VisEventCodes.visEvtConnect),
eventSink, "", "Added connections handler" );

Hope this helps,
 
S

Scott A. Guyer

Thanks Markus and Bill. I think the event code -32768 was my problem.
But the sink member variable strikes me as a good idea. Now if I can
just figure out what to do what those System.__ComObject's in the
event callback. ;-)

Cheers,
-Scott
 

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