Free Support Forum - aspose.com

Access is denied Aspose.Word

Hi
We seem to get this error whenever we update our web site , and it only happens the first time the aspose component is accessed ( in this case to write metadata to a word doc ) , the second time and subsequent times, everything works…
Any ideas as to what could cause this?

When do you get access denied, when reading a file or saving?

Aspose.Word opens file for reading only and in read shared mode so it can be read simultenaously by others. It then closes it quickly, as soon as finished reading.

Make sure you use latest version of Aspose.Word hotfix.

This does not refer to the file that Aspose is opening, but Aspose dll itself…
I have found reference to indexing server causing this by locking dll’s in the bin folder of a web site, but have not been able to reproduce so have not been able to exclude this as a cause.

a clarification - this is happening even when I read a word doc as a blob from SQL server - and it’s probably not the aspose dll itself that is locking as I stated above.

The weird thing is that this works for some users and not others. So it seems related to permissions - internally, do you create temp files when you instantiate the word object? I’m trying to work out how one user gets “access denied:Apose Word” when the following code is run and not other users .

Aspose.Word.Word word = new Aspose.Word.Word();

string licenseFile = _AsposeLicensePath;

if (File.Exists(_AsposeLicensePath))

{

Word.SetLicense(licenseFile);

}

MemoryStream msIn = new MemoryStream(docBytesIn);

MemoryStream msOut = new MemoryStream();

Aspose.Word.Document doc = word.Open(msIn);

doc.BuiltInDocumentProperties[“Title”].Value = title;

doc.BuiltInDocumentProperties[“Subject”].Value = subject;

doc.BuiltInDocumentProperties[“Author”].Value = author;

doc.BuiltInDocumentProperties[“Company”].Value = company;

doc.Save(msOut,Aspose.Word.SaveFormat.FormatDocument);

byte[] docBytesOut = msOut.ToArray();

return docBytesOut;

Thanks
Antony Day


In your scenario no temporary files are used. We only create temporary image files when saving into a memory stream and using HTML or PDF format.

What line in the code is throwing the exception, do you know?

Hi Ronan, thx for quick reply - getting a bit weird now - I tried this, broke the code out into a page so I could see which line throws the exception - does not even get to the catch - the exception thrown by the site is:

System.IO.FileLoadException: Access is denied: ‘Aspose.Word’.


note that this does not happen for some user accounts

---------------
int i = 0;
try

{

Utility.Clients.DOJ.Document d = new Utility.Clients.DOJ.Document();

byte[] docBytesIn = d.GetDocumentVersionBytes(191);

Aspose.Word.Word word = new Aspose.Word.Word();

i++;

MemoryStream msIn = new MemoryStream(docBytesIn);

MemoryStream msOut = new MemoryStream();

i++;

Aspose.Word.Document doc = word.Open(msIn);

i++;

doc.BuiltInDocumentProperties[“Title”].Value = “t”;

doc.BuiltInDocumentProperties[“Subject”].Value = “s”;

doc.BuiltInDocumentProperties[“Author”].Value = “a”;

doc.BuiltInDocumentProperties[“Company”].Value = “company”;

doc.Save(msOut,Aspose.Word.SaveFormat.FormatDocument);

i++;

byte[] docBytesOut = msOut.ToArray();

}

catch

{

Response.Write(i.ToString());

}

Sorry, I'm a bit lost, can we take it slowly:

1. Do you expect any help from me on this issue? It is very difficult for me to recommend something as it looks the problem might be in your application, not in Aspose.Word.

2. Do you know much about IIS user account, authentication settings for the users of the application, security settings for the files being accessed, security settings and sharing mode for the database?

3. So what line is actually throwing the exception and what difference can you find between the user accounts that throw and dont' throw.

This issue was caused by the authenticated web user not having write permissions on the temporary Asp.net files folder.
Thanks for the assistance in finding this , Roman.

Hi,

Which folder do you mean by “temporary Asp.net files folder”, we sometimes get the access denied as well, and then for no reason it will go away.

Thanks,
Kris