Hosted Word is not released with a C# add-in

A

Alex

Hello Peter,

"Peter Huang" said:
Hi

We are still researching the issue.
Thanks for your patience.

Best regards,

Peter Huang
Microsoft Online Partner Support

Over a month and a half passed since your last comment on the issue.

Can you please give me an update?

Thank you.


Best wishes,
Alex.
 
A

Alex

Hello Peter,

I get the feeling that this issue is being ignored.

Would you mind commenting on it?

Here's my message from almost a month ago:


Hello Peter,

"Peter Huang" said:
Hi

We are still researching the issue.
Thanks for your patience.

Best regards,

Peter Huang
Microsoft Online Partner Support

Over a month and a half passed since your last comment on the issue.

Can you please give me an update?

Thank you.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi Alex,

It is very strange. I do have replied to your issue on 5.27,6.3 and 7.14. I
am not sure what had happened that you did not see the three posts.
Here I will repost my reply for you. If you still have any concern, can you
post your email so that I can contact you via another approach. Or please
repost a new post in a new thread.

Thanks!

============================================================================
=
I have replied you in on 5.27th. In case there is any error, I repost my
post here.
Also I attach the attachment too.
Mainly we need to release the document in the host app when exit.

Here is a C# app which host the DSOFramer, and it will release the
Document. We need to ensure the code will be called when we close the fom.
private void button2_Click(object sender, System.EventArgs e)
{
Object mvalue=Missing.Value;
Word.DocumentClass
doc=(Word.DocumentClass)axFramerControl1.ActiveDocument;

wordApp=(Word.ApplicationClass)doc.Application;
axFramerControl1.Close();

wordApp.Application.Quit(ref mvalue,ref mvalue,ref mvalue);
Marshal.ReleaseComObject(wordApp);
}

=========================================================
From: (e-mail address removed) ("Peter Huang" [MSFT])
Date: Fri, 27 May 2005 09:40:46 GMT
Subject: Re: Hosted Word is not released with a C# add-in - update
Newsgroups: microsoft.public.office.developer.com.add_ins

Hi

Based on my research, we need to release the document explicitly.
Here I attach the sample which will show the approach.
You may have a check the HostApp in the attachment.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
===============================================================
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cindy M -WordMVP-

Hi Peter,
It is very strange. I do have replied to your issue on 5.27,6.3 and 7.14.
I don't see these replies, either. The last one from you appearing here in
the group says you're still researching the issue. Looks like the newsgroup
lost them...

FWIW, I'm also interested in the issue's resolution, so I would appreciate
it very much if you could post all the relevant material to the NG :)

BTW, the attachment is missing in your duplicate posting (to which I'm
replying)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
A

Alex

Hello Peter,

Thank you for your reply.

"Peter Huang" said:
Hi Alex,

It is very strange. I do have replied to your issue on 5.27,6.3 and 7.14. I
am not sure what had happened that you did not see the three posts.
Here I will repost my reply for you. If you still have any concern, can you
post your email so that I can contact you via another approach. Or please
repost a new post in a new thread.

Since there is no sign of these posts on the MS news server or in Google's archive (http://tinyurl.com/84le3), I believe that they did not make it to usenet. Perhaps a technical glitch.

Also I attach the attachment too.

The attachment did not make it.

Mainly we need to release the document in the host app when exit.

Here is a C# app which host the DSOFramer, and it will release the
Document. We need to ensure the code will be called when we close the fom.

This does not solve my problem.

I'll try to explain:

There are some applications that host Word, similar to DSOFramer but not using that exact control.
These are external applications which I have no control over. I cannot "tell" the application how to release Word.

These applications release Word just fine when there are no Add-ins present.

When I add an Add-in that hooks one (or more) of Word's events (e.g., ApplicationEvents3_QuitEv­entHandler), Word does not get released.


Best wishes,
Alex.
 
A

Alex

Hello Peter,

I see a potential problem with your proposed solution:

"Peter Huang" said:
Here is a C# app which host the DSOFramer, and it will release the
Document. We need to ensure the code will be called when we close the fom.

private void button2_Click(object sender, System.EventArgs e)
{
Object mvalue=Missing.Value;
Word.DocumentClass
doc=(Word.DocumentClass)axFramerControl1.ActiveDocument;

wordApp=(Word.ApplicationClass)doc.Application;
axFramerControl1.Close();

wordApp.Application.Quit(ref mvalue,ref mvalue,ref mvalue);
Marshal.ReleaseComObject(wordApp);
}

I suspect that wordApp.Application.Quit will exit other instances of Word windows that use the same Word process.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi

Based on my test, application.quit will not quit the word process if
another application is holding reference on it.
e.g. Outlook will lauch a winword, although the dsoframer will use the same
process, but the application.quit will not quit the word process.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Hello Peter,

Thank you for your reply.

"Peter Huang" said:
Based on my test, application.quit will not quit the word process if
another application is holding reference on it.

Tha is good to know.
e.g. Outlook will lauch a winword, although the dsoframer will use the same
process, but the application.quit will not quit the word process.

This brings me to another issue.

Is it possible to force a host (dsoframer or otherwise) to launch a new instance of Word instead of attaching to an existing one?

Basically, what I am trying to achieve is to make sure that my add-in is only active in Word instances that are not embedded in other applications.
However, when a host attaches to an existing Word instance, it will have my add-in there.


Best wishes,
Alex.
 
P

Peter Huang [MSFT]

Hi

Word's behavior, the Addin is loaded by word instance by design.
As the word startup, it will check the registry under in the Addins, once
it is found word will try to load it. That is to say the behavior will
persist across all the word instance on certain machine.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Hello Peter,

"Peter Huang" said:
Hi

Word's behavior, the Addin is loaded by word instance by design.
As the word startup, it will check the registry under in the Addins, once
it is found word will try to load it. That is to say the behavior will
persist across all the word instance on certain machine.

I understand this.

However, my add-in can check for certain conditions on start-up and deactivate itself (basically, disable its functionality).

Thus my question:
 
P

Peter Huang [MSFT]

Hi

I think it is hard to do that. This the OLE's default behavior, just as the
outlook invoking word.
To customize the behavior we even need to change the word's code which is
not possible.

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex

Hello Peter,

"Peter Huang" said:
I think it is hard to do that. This the OLE's default behavior, just as the
outlook invoking word.

I was afraid it would be the answer.

Thank you anyway.


Best wishes,
Alex.
 

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