COM AddIn Causes Error When Outlook Closes

F

Fred Block

Hi All,

I've build a COM AddIn a while back that worked fine. The AddIn consists of
an ActiveX DLL and an OCX. The OCX was built for displaying a PropertyPage
in Outlook's Options dialog for this AddIn. I've recently updated some code
in only the DLL and now Outlook throws a fault (errors) when closed "only"
if the Options dialog has been opened. If Outlook is started and closed
"without" opening the Options dialog, then no error occurs and Outlook shuts
down normally. This behavior occurs against Outlook 2000 under Windows 2000
SP3 and Outlook 2003 under WinXP SP2. Any ideas?

Also - would I be correct in creating separate VB projects to build each of
the components (the DLL and the OCX) or would I need to use a VB Project
Group (I belive I built them separately in the past) to do this correctly?

And while I'm at it - one more... should the OCX be compiled first and
referenced in the DLL project? (Again - it wasn't in the past)...

I hope I covered my bases here to help troubleshoot this... Thanks for all
the help in advance!

Kind regards - Fred
 
K

Ken Slovak - [MVP - Outlook]

I've compiled both ways, with a project group and as separate projects, it
doesn't make a difference. Unless you change the public interface of the DLL
or OCX you wouldn't need to recompile the unchanged project.

What error gets thrown?
 
F

Fred Block

Hi Ken,
I've compiled both ways, with a project group and as separate projects, it
doesn't make a difference. Unless you change the public interface of the
DLL or OCX you wouldn't need to recompile the unchanged project.

Thanks for confirming this! Everything loads OK but I wasn't sure and needed
to ask...


What error gets thrown?

In the DRWTSN32.LOG file, the fault line reads:

FAULT ->10008bc0 ???

The only other reference to this address in the LOG file is above the fault
and is as follows:

State Dump for Thread Id 0x810

eax=002353bc ebx=11002870 ecx=3a431f10 edx=0006f0d4 esi=00000000
edi=0006f0d4
eip=10008bc0 esp=0006f084 ebp=0006f0e4 iopl=0 nv up ei pl zr na po
nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000
efl=00000246


Any of this shed some light?!?

Thanks for your support Ken!

Kind regards - Fred
 
K

Ken Slovak - [MVP - Outlook]

It doesn't shed any light for me :)

Are you positive you are releasing all your Outlook derived objects when the
last Explorer or Inspector closes and that On_Disconnection fires?

What I'd do is set a breakpoint in debug mode on your code that releases all
your objects and in On_Disconnection to see if any errors are thrown there
and if so what they are.
 
F

Fred Block

Hi Ken,
Are you positive you are releasing all your Outlook derived objects when
the last Explorer or Inspector closes and that On_Disconnection fires?

What I'd do is set a breakpoint in debug mode on your code that releases
all your objects and in On_Disconnection to see if any errors are thrown
there and if so what they are.

I've added a MsgBox as the last line of the
IDTExtensibility2_OnDisconnection event. When exiting Outlook, the message
box appears only when I have NOT opened Outlook's Options dialog (also:
Outlook closes normally). If I start Outlook and open the Outlook Options
dialog, my MsgBox does NOT appear and then I get the Outlook error
(Microsoft Outlook ghas encountered a problem...) when I exit Outlook.

Any other ideas?

I'm going to look at what's being loaded and make sure all is closing. I
just find it a bit weird that I haven't changed anything that would have
caused this anomaly in the past 6 months (only code that refers to field
names of a third party application).

Thanks again for hanging in there Ken!
- Fred
 
K

Ken Slovak - [MVP - Outlook]

In Options are you opening a property page? If so I'd check in that code to
make sure everything is being released and that no errors are being thrown
and not handled. Otherwise I'm out of ideas. Many of my addins use a
property page for configuration and I haven't had any problems with those at
all.
 
F

Fred Block

Hi Ken,
In Options are you opening a property page? If so I'd check in that code
to make sure everything is being released and that no errors are being
thrown and not handled. Otherwise I'm out of ideas. Many of my addins use
a property page for configuration and I haven't had any problems with
those at all.

Actually - I do not need to open the actual Property Page (OCX I created) at
all. Simply opneing the Options dialog and closing it right away is all it
takes to have Outlook throw the error. I'm going to look into all of the
Outlook object creation calls and make sure they're being released.

I will advise... Thank again Ken!

Kind regards - Fred
 
K

Ken Slovak - [MVP - Outlook]

If you select Tools, Options and are handling the event that shows your
property page it's being instantiated. Whether or not you display the tab
your property page is on.
 
F

Fred Block

Hi Ken,
If you select Tools, Options and are handling the event that shows your
property page it's being instantiated. Whether or not you display the tab
your property page is on.

Most of my code is from an example from MS Press "Building App's w/ MS
Outlook 2000". In my OCX code, I'm declaring:
Dim objSite As Outlook.PropertyPageSite

This get's set in the UserControl_InitProperties Sub:
Set objSite = Parent

I don't see where this is being unloaded. If it needs to be explicitly,
where would I do this?

THanks in advance!

Kind regards - Fred
 
K

Ken Slovak - [MVP - Outlook]

Randy's book is a very good starting point, certainly.

Handling the Application.OptionsPagesAdd event means that when Tools,
Options is selected by the user that your property page (OCX) is being
instantiated. Usually it's handled something like this:

Private Sub objOutlook_OptionsPagesAdd(ByVal Pages As Outlook.PropertyPages)
Dim strPPTitle As String

On Error Resume Next

strPPTitle = "My Addin" 'or whatever
Pages.Add "MyAddinPP.UserControl1", strPPTitle

Err.Clear
End Sub

In the OCX you init your objects in the UserControl_InitProperties Sub, as
you indicated. BTW, if you need a trusted Outlook Application object for the
Outlook security you would get it as follows:

Implements Outlook.PropertyPage
Dim objSite As Outlook.PropertyPageSite

Private Sub UserControl_InitProperties()
On Error Resume Next

Set objSite = Parent
Set g_olApp = objSite.Application 'declared globally in a code module


Then, you release all your objects in the UserControl_Terminate() Sub.

To handle clicks on OK or Apply you have to set objSite.OnStatusChange when
one of the settings in your user control is changed. You usually set a dirty
Boolean, which is picked up in the Property Get PropertyPage_Dirty() handler
and do any saving of values or calls back to the COM addin from the
PropertyPage_Apply() sub.
 

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