Strange issue in Excel addin

B

Bhimasena

Hi!

I have an Excel COM addin (not created by MSTO, but this is the closest
forum I found) implemented in VB.NET, Office 2003
Excel application reference that I recieve upon addin connection is stored
in a global variable.
The addin among other features handles an event from external COM application.
Now the issue itself: If within the event handler I access any
property/method of the Excel application object, when I later close Excel,
the process Excel.exe is still running. It seems like an additional reference
to its object is created from within the event handler and is not released,
but I am not able to track it down.

This issue does not reproduce in Word.

Any ideas?
 
B

Bhimasena

Hi, Simon!

I store the reference to Excel application in a global variable that is
initialized in OnConnection handler. The variable is set to Nothing in
OnDisconnection.
It is accessed all throughout the add-in code. The problem occurs _only_
when I access it from within a specific event handler. If the only code I
have in the handler is the access to this variable, I reproduce the problem,
so the other code there is not related. I tried reducing the reference
counter by calling ReleaseComObject at the end of my event handler, but it
did not help.

Another clarification - this variable is declared with late binding because
the same code runs within Word and Excel, so it can be resolved as
Word.Application or as Excel.Application accordingly.

As for the support article you have linked, it is of no relevance in this
case - the problem still happens even if the guidelines are followed strictly.

--
Regards,
Ilya

Simon Murphy said:
Hi
Its pretty easy to pick up accidental implicit refs to the Excel app when
declaring variables. That would give you the behavoir you are seeing.
Are you sure you are correctly qualifying your variable declarations?

You may want to check this too as you are using .net:
http://support.microsoft.com/kb/317109

Cheers
Simon
Blog: www.smurfonspreadsheets.net
Website: www.codematic.net Excel development, support and training
 
J

Jialiang Ge [MSFT]

Hello Bhimasena,

From your post, my understanding on this issue is: your excel.exe is not
terminated when you close the Excel, due to a event handler in your add-in.
You have already tried the method: ReleaseComObject and followed the kb
article: http://support.microsoft.com/kb/317109, but it did not help. If
I'm off base, please feel free to let me know.

Because you said that the add-in runs well for Word, would you let me know
whether the event handler also runs in Word? What is that event handler
for? Would you send me some sample codes so that I can reproduce the issue
on my side?

Besides, based on my experience, my guess is that :
1. a circular reference of objects result in your problem. For instance,
your Application object has a reference to a delegate holding a reference
to the event handler, and the event handler also has a field which can
optionally point back to the Application object. Such a circular reference
may cause that the Application object cannot be released even if you call
ReleaseComObject. Please check it and let me know if there does exist a
circular reference in your code.
2. some additional references are created in your event handler but you do
not notice them. For instance,
oBook = oExcel.Workbooks.Add() will create an additional reference to
Excel.Workbooks object. Thus it should be modified as
dim oBooks as Excel.Workbooks
oBooks = oExcel.Workbooks
oBook = oBooks.Add()
and finally release the oBooks with oBooks = Nothing

Sincerely,
Jialiang Ge ([email protected], remove ¡®online.¡¯)
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box ¡°Tools/Options/Read: Get 300 headers at a time¡±
to see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided ¡°AS IS¡± with no warranties, and confers no
rights.
 
J

Jialiang Ge [MSFT]

Hi Bhimasena,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bhimasena

Hi, Jialiang!

Currently I have a workaround implemented for this issue.
I will however try to isolate the problem into a sample add-in as soon as I
have time to attend to it. If I manage to reproduce the issue on sample I
will probably send it for your consideration.
 

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