Access Denied error each time I compile

Access is denied: ‘Aspose.Pdf’.

Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.

Exception Details:
System.IO.FileLoadException: Access is denied:
‘Aspose.Pdf’.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Aspose.Pdf' could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = Aspose.Pdf, Version=3.1.6.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
(Fully-specified)
LOG: Appbase = file:///D:/Desktop/DCW20/Datacom
LOG: Initial PrivatePath = bin
Calling assembly : Datacom, Version=1.0.2406.9046, Culture=neutral, PublicKeyToken=null.
===

LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/datacom/b6595875/efa5f4e0/Aspose.Pdf.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/datacom/b6595875/efa5f4e0/Aspose.Pdf/Aspose.Pdf.DLL.
LOG: Attempting download of new URL file:///D:/Desktop/DCW20/Datacom/bin/Aspose.Pdf.DLL.

Stack Trace:

[FileLoadException: Access is denied: 'Aspose.Pdf'.]
DWC.Dealer.Contract.supportrequest_acknowledgement.Page_Load(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

I recieve this error everytime my project is recompiled. The only workaround that I've found is to restart the IIS service each time I compile. This was an annoyance, but workable. However, it maeans that I cannot debug any code that uses Aspose Words or PDF in VS.NET since it forces a compile on debug run. So, I must fix this ASAP (as I have a piece of code using Aspose Words and PDF that needs to be debugged).

I have tried giving full control to the ASPNET and IUSR users, on the /bin directory.

I have tried adding ASPNET and IUSR to the administrator group.

I have tried setting the project reference to copy local. I have tried copying dlls into the /bin directory and directly referencing them instead. I have tried deleting all copies of Aspose.*.dll on my machine, reinstalling, and resetting permissions.

I am not running Index Service.

Any ideas?

I think this problem should be caused by the setting of the server but I am not familiar with this issue. Can you please try it at another machine?

I get the same error when deploying new code to the production server. I must restart IIS on it to work around the permission denied error on any page using the Words or PDF assembly.

If it helps narrow down the issue, the problem still occurs when I only deploy the site dll and leave the Aspose.*.dll files unchanged on the server.

Are there any other permissions that need to be changed? I’ve tried giving full control to ASPNET and IUSR in every location I can think of, on my development server, but nothing has helped.

Here is the comment from our webmaster:

I have never encountered this problem before. First thing I would check is that they dispose of the Aspose.Pdf object properly when they are done using it in their code.

Can you please send my the code and let me test it?

This is the Aspose related code for one of the pages. Note that it will not run a single time after a compile, until I restart IIS. After that, however, I can run it as many times as I want and it never gives the error again. So, it doesn’t seem to be a problem with the code locking resources or anything along those lines (otherwise, subsequent execution should cause the error as well).

Even if I compile the code with no changes, the new build will give the error until an IIS restart Same if I deploy that newly built DLL to a clean production server.

Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense(“Aspose.Pdf.lic”);

Aspose.Words.License WordsLicense = new Aspose.Words.License();
WordsLicense.SetLicense(“Aspose.Words.lic”);

Document sourceDoc = new Document(pdfpath + @"\Support_Letter_Templates\support_letter_template.doc");

DataTable table = new DataTable();

table.Columns.Add(“Salutation”);
table.Columns.Add(“First”);
table.Columns.Add(“Last”);
table.Columns.Add(“DealerName”);
table.Columns.Add(“CompanyName”);
table.Columns.Add(“Address”);
table.Columns.Add(“City”);
table.Columns.Add(“State”);
table.Columns.Add(“Zip”);
table.Columns.Add(“SalesRep”);

table.Rows.Add(new object[] {Session["_Salutation"].ToString(),
Session["_firstname"].ToString(),
Session["_lastname"].ToString(),
Session["_dealer"].ToString().Trim(),
Session["_customercompanyname"].ToString(),
Session["_address"].ToString(),
Session["_city"].ToString(),
Session[“State”].ToString(),
Session["_zip"].ToString(),
Session["_salesrep"].ToString()});

sourceDoc.MailMerge.Execute(table);

MemoryStream ms = new MemoryStream();
XmlDocument xml = new XmlDocument();

sourceDoc.Save(ms, Aspose.Words.SaveFormat.FormatAsposePdf);

ms.Position = 0;
xml.Load(ms);

Pdf pdf = new Pdf();

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.BindXML(xml, null);

ms.Close();

pdf.Save(pdfpath + “\” + ReqId + “_Support_Letter.pdf”);

Sorry for this inconvenience. Since this problem is strange, I need your help you get more detailed info.

1) From your code I can see you are using Aspose.Words too. Do you mean Aspose.Words does not have such problem? Can you please try using Aspose.Words only in your project? If Aspose.Words work well, this problem should not be caused by server setting.

2) I don't know if this problem is caused by some changes in the new version. Can you please try some provious version of Aspose.Pdf and tell me the result?

  1. It just depends on which component is instantiated first. If I comment out the PDF license line, I get the same access denied error about Words.

    2) I’ve tried most of the versions from 3.x till current, while the project has been in development. Always have had that issue.

Thanks for your reporting.

We will investigate these issues and try to find out reasons. It may take us a few days.

Since it does not work for other components, it must be a server setting issue. We are not familiar with this so you’d better consult expert in this field.

Everything else on the server is working perfectly. There was no trouble until we introduced the Aspose components, and then only trouble on the pages that reference those DLLs.

Let’s hear some more ideas for fixing the problem. If I tell my boss that we’ve been abandoned on this issue, I’m sure he will just dispute the charges for the components and it will be a hassle for all of us. I don’t want that.

There are some comments from other developers of our company:

  1. It may be related to license code. Please ask them to comment out all license code and see what happens.

If this is the caused, maybe he has to change the settings according to http://www.aspose.com/Wiki/default.aspx/Aspose.Purchase/HowToFixCSPException.html.

  1. I have done some digging and found the following articles (all relating to the error):

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=291953&SiteID=1

http://forum.ayanova.com/InstantForum412/Topic1163-99-1.aspx

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2798

I have tried to list them in order of good answers. It does appear to be a permissions issue. Please let me know if the above articles do not help and I will be glad to assist further.

Hello, I was wondering if you found a fix for this just yet? His experience isnt an isolated one because I have been getting the same thing since I started using the Words control about 2-3 months ago. I just dealt with it until now, it’s starting to bug me.

I got around it the same way he did, but I went into Task Manager and ended the process for my aspnet_wp.exe application then in the Microsoft.Net/Temporary Internet Files/ deleted the folder that my app was in.

That would work for a few times of running the app. But would soon come back to an Access Denied.

How do you properly dispose this component? I am late binding and not global variables declared for this control. Plus I dont recall seeing a ‘Dispose’ method anywhere.

My guess is that IIS is not releasing the objects. After my project is finished and closed I try to delete the folder in the Microsoft.Net/Temporary Internet Files and cannot because a file is being used.

Anymore information needed let me know. I would really like to find a fix for this.

thanks.

[UPDATE:] After reading the post before mine here there was a link that seemed to fix it:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=291953&SiteID=1

I basically went into my Temporary Internet Files in Microsoft.Net and gave everyone Read/Write permissions and it has worked so far. probably not the best security fix for it, but it works so far.

I will test this for a few days and see if I get the errors any longer. Thanks for the time on this.

I had the same problem and here is how I fixed it:

  1. Quite Visual Studio.
  2. Stop IIS Admin and Web Service on your computer.
  3. Start Task Manager and see there are no more devenv.exe processes are running. If some running, kill them.
  4. Delete all folders from C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files.
  5. If some folders cannot be deleted because access is denied, you have to reboot the computer.

That solved the mysterious Access Denied problem.

I was never able to reliably fix the problem. However, upgrading from .NET 1.1 to .NET 2.0 made it stop. If you’re having the problem too and running 1.1/2003, try upgrading to 2.0/2005.