Application Object Cast

M

Michael Cierkowski

I am developing a COM addin for Excel and I run into a major issue. This is
probably the strangest thing I have seen. In the OnConnection method I cast
the application object to the type of
Microsoft.Office.Interop.Excel.Application in order to attach some events.
Here is things get strange. If I open Excel then all is ok, my addin loads
and works correctly. If I open an existing document by double clicking my
addin loads but the workbook isn't visible for about 40 seconds and then all
is ok. If I comment out the cast then it works fine. I created a test
project and the only line of code that I added is this in the OnConnection
method:

Microsoft.Office.Interop.Excel.Application test =
(Microsoft.Office.Interop.Excel.Application)application;


and the same thing happens. If I comment this out it works.. now if I don't
comment it out I and I double click an excel workbook to open, Excel will
open with no workbook visible but if I make a dialog box show up (either by
Help - About; File - Open; or programaticly using MessageBox.show. then the
work book becomes visable immediatly.

Please could anyone help on this one.. I am at wits end and am almost out of
hair to pull out.

Michael
 
M

Michael Cierkowski

Still working on this.. I have found that for my Word addin application is
of type Word.Application but in my Excel addin it is passed in as a
System.__ComObject.. My question is how do I get the System.__ComObject to a
Excel.Application.

Does anyone have any ideas out there????
 
P

pavan

Hi,
I think your problem is more to the type of the object that is being
passed. Your issue might be because of some sort of race condition or a
deadlock. That's what I can think of as of now.

Regards ,
Pavan
 

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