Error: "The requested resource is in use"



I am having trouble viewing a generated document soon after it had been generated by Aspose.Word. I get the following error:

The requested resource is in use.
at SHDocVw.IWebBrowser2.Navigate(String URL, Object& Flags, Object& TargetFrameName, Object& PostData, Object& Headers)
at AxSHDocVw.AxWebBrowser.Navigate(String uRL, Object& flags, Object& targetFrameName, Object& postData, Object& headers)
at PrintManager.frmView.NavigateFirst()

I am using AxWebbrowser control to navigate to this new page. I have this code at the end of the document generating code:

FileStream fs=null;
fs = new FileStream(oTemplate.ToString(), FileMode.Open, FileAccess.Read);
oDoc = new Document(fs);
if(oDoc.ProtectionType != ProtectionType.NoProtection)


oDoc.Save(oName.ToString(), SaveFormat.FormatDocument);

if(oDoc!=null) oDoc=null;
if(fs!=null) fs.Close(); // closes template file

And here's the NavigateFirst() method I am using:

public void NavigateFirst()
if(!navigated && dvDocs.Count > 0 && this.InputFinished)
wbDocs.Navigate(sDir + dvDocs[0]["GFileName"], ref oMissing, ref oMissing, ref oMissing, ref oMissing);
// navigate to first document, after atleast one is generated
this.navigated = true;

Is there a way to make sure the generated document is closed completely using Aspose.Word? How come there isn't a Document.Close() method?

Thanks for your help.




Thank you, we’re looking into this issue, will reply you soon.


Document does not have Close() because it never keeps any resources open.

If you open a document from a file, it creates a stream, reads and closes it. If you save a document to a stream, it creates, writes and closes.

In your case you just pass a stream to Aspose.Word and close it yourself so Aspose.Word has absolutely nothing to do. It just writes to the stream.

I don’t think the issue is caused by Aspose.Word in this case.

Just in case, try using the latest version of Aspose.Word where we switched away from using Win32 structured storage interface and work with the file directly.