Outlook 2000 w/ VB.NET -- QueryInterface failed -- UCOMIConnectionPointContainer.FindConnectionPoint

M

Matt Miller

Hi,
I'm developing an addin for Outlook using VB.NET, and I'm running across
some problems w/ getting everything working for Outlook 2000.

First, I find that in the OnConnection routine, i can't cast the passed-in
application object to Outlook.Application if it's declared withevents. This
causes the following exception:

System.Runtime.InteropServices.COMException (0x80040200): Exception from
HRESULT: 0x80040200.
at
System.Runtime.InteropServices.UCOMIConnectionPointContainer.FindConnectionPoint(Guid&
riid, UCOMIConnectionPoint& ppCP)
at
Microsoft.Office.Interop.Outlook.ApplicationEvents_10_EventProvider.Init()
at
Microsoft.Office.Interop.Outlook.ApplicationEvents_10_EventProvider.add_NewMail(ApplicationEvents_10_NewMailEventHandler
)
at
Microsoft.Office.Interop.Outlook.ApplicationEvents_10_Event.add_NewMail(ApplicationEvents_10_NewMailEventHandler
)
at Spamagogo.Connect.set_MyOutlook(Application WithEventsValue)
at Spamagogo.Connect.OnConnection(Object application, ext_ConnectMode
connectMode, Object addInInst, Array& custom)


I figure this is a versioning problem, and i've tried to reference interop
assemblies for Outlook 2000, but I don't think they exist. I've tried
rebuilding the interop assembly -- no dice (it runs, but i still get this
error) Since i really only care about the newmail event, and Redemption's
MAPIUtils.NewMail event works, I decided to just use that. However, this is
where I run into an interesting problem.

I have a button in the standard toolbar that one can press to cause an
action.
When this button is pressed, code runs fine.

When the MAPIUtils.NewMail event triggers, I get "QueryInterface failed for
XXX" where XXX is the application object OR the Namespace object (if I have
already made the Namespace object returned by Outlook.Application.Session
into a global variable)

I've tried all sorts of things to trick outlook into working -- i've taken
the newmails as they come in, put them into an arraylist, started a timer,
and handled the timer.tick() event with an action. Still get the
queryinterface failed error. I've started a background thread to sit there
and just take things out of the aforementioned arraylist (still happens)

I'm really at a loss for why my code, in the SAME instance of outlook, would
run when it's handling one event but not another. What's so different about
the MyButton.Click event from any of the other places that i've tried to get
this code to execute?


The problem here might just be to go back to the beginning of the post and
fix the versioning problem. That would be my primary choice, but I'm really
at a loss here.


Anything anyone can do to help would be greatly appreciated.

Thanks,
Matt Miller
(e-mail address removed)
 

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