Hi,
I have a web application (asp.net) in which I need to open and edit a word file.
I wrote c# code which I tested (and worked perfectly fine) in a winform application.
When I tried to use it in my asp.net application I got errors:
1. I didn't use impersonate, and I couldn't open the word file using the following command:
Microsoft.Office.Interop.Word.Document doc = oWord.Documents.Open(filename, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
I got this error:
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied.
I tried fixing it (still without using impersonate), following this:
http://stackoverflow.com/questions/3477086/accessing-office-word-object-model-through-asp-net-results-in-failed-due-to-the[
^]
and this:
http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/006cbbac-101a-40ea-ae16-d59a7a2da8b1/[
^]
I couldn't find the WINWORD.EXE that they were talking about under the given directory, and also couldn't find the CLSID in the DCOM Config
2. I tried using the impersonate, and added the administrator userID and password
<identity impersonate="true" userName="domain\Administrator" password="password" />
Then the doc WAS opened, but I couldn't use the document at all due to the following error I got:
The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
As I figured it, it happens because one of 2 reasons:
a. There's some kind of popup that prevents editing the document (since it's not really open yet)
b. The Impersonate actually is responsible for that, since I open the file with one identity and try to edit it with another
I couldn't do neither of the following commands:
doc.Save();
doc.Activate();
for (int i = 1; i < doc.Sections.Count + 1; i++)
(In the last one it fails getting the sections)
Anyone knows how I can resolve this issue (I prefer not using the impersonate, if possible)
Thanks