System.IO.FileNotFoundException

I am getting System.IO.FileNotFoundException when referencing the dll from a SharePoint 2013 Event Receiver: Could not load file or assembly 'Aspose.Pdf, Version=10.2.0.0, Culture=neutral, PublicKeyToken=6947866647e416ec' or one of its dependencies. The system cannot find the file specified.

Please let me know what additional information you need to assist with this issue.

Here is the code:

public class PDFUpdaterTestReceiver : SPItemEventReceiver
{
///


/// An item was added.
///

public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);

if (properties.ListTitle == "Documents")
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(properties.WebUrl))
{
using (SPWeb web = site.OpenWeb())
{
try
{
//get list item
SPList list = web.Lists[properties.ListId];
SPListItem item = list.Items[properties.ListItem.UniqueId];
SPFile file = item.File;
MemoryStream myStream = new MemoryStream();
byte[] bf = file.OpenBinary();
MemoryStream ms = new MemoryStream(bf);

//Aspose PDF Classes - get and modify document links
Document document = new Document(ms);

foreach (Aspose.Pdf.Page page in document.Pages)
{
//get links for the current page
AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial));
page.Accept(selector);
IList linksList = selector.Selected;

//loop through links and update as needed
foreach (LinkAnnotation link in linksList)
{
string linkURI = (link.Action as Aspose.Pdf.InteractiveFeatures.GoToURIAction).URI;
if (linkURI.Contains("intranet.chop.edu"))
{
//need to update GoToURIAction
link.Action = new Aspose.Pdf.InteractiveFeatures.GoToURIAction(linkURI + "?CHOP=atchop");

//GoToRemoteAction goToR = (GoToRemoteAction)link.Action;
// Next line update destination, do not update file
//goToR.Destination = new XYZExplicitDestination(document, 2, 0, 0, 1.5);
// Next line update file
//goToR.File = new FileSpecification("c:/pdftest/PDFInput (1).pdf");
}
}
}

//save document with updated links
//document.Save("c:/pdftest/ResultantFile.pdf");
document.Save(ms);

//update the list item
string linkFilename = file.Item["LinkFilename"] as string;
file.ParentFolder.Files.Add(linkFilename, ms, true);


}
catch (Exception ex)
{
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.ErrorMessage = "Error : " + ex.Message;
}
}
}
});
}
}
}

Thanks.

Hi John,


Thanks for contacting support.

Please ensure that you have referenced correct product binaries (Aspose.Pdf.dll) according to project target platform i.e. If your project is targeting .NET Framework 4.0, ensure to reference Aspose.Pdf.dll from net4.0 folder from product installation directory. In case you still face the same issue, please share some sample project so that we can test the scenario in our environment. We are sorry for your inconvenience.

Hi,

I was able to resolve this issue. I added the dll to the virtual directory "bin" folder for the wrong web application. Once it was added to the correct folder I was able to reference it with no issue.

Thanks.

Hi John,


Thanks for the sharing the feedback.

We are glad to hear that your problem is resolved. Please continue using our API’s and in the event of any further query, please feel free to contact.