Hi can I get some idea on how to fix this, I'm getting this error every time I hit my function that sends pdf files through email, I'm using microsoft word 2007 in my machine heres the error and my code, I'm getting an error on wdapp.Documents.Open
Error
System.Runtime.InteropServices.COMException (0x80010105): The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)) at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform) at Choc.Filehandlr.ProInte.ConvertWordToPDF(List`1 fileList, String FileNo, String bUnit) in C:\Users\monkeydluffy\Desktop\Choc.Filehandlr\Choc.Filehandlr\Choc.Filehandlr\Common\Choc.Integ.cs:line 191pdfFiles coutn : 1trace111trace222Could not find file 'c:\ConvertLocation\botique\Ace-botique-AT14\Ace-botique-no16-copperwire.pdf'.sp Context: http://sharepoint/ace-botique/useritem in Files Collection: 6returning file count: 1filecount: 1 filename: c:\ConvertLocation\botique\Ace-botique-AT14\file1.docx
wdapp.Visible = false;
wdapp.ScreenUpdating = false;
foreach (FileInfo wordFile in wordFiles)
{
// Cast as Object for word Open method
Object filename = (Object)wordFile.FullName;
//Test trace only
EventTracer.Instance.Trace(Constants.TraceSettings.ERRORSONLY_Option, string.Format("filename: {0}\r\n", filename));
// Use the dummy value as a placeholder for optional arguments
wdInterpo.Document doc = wdapp.Documents.Open(ref 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);
doc.Activate();
//Test trace only
EventTracer.Instance.Trace(Constants.TraceSettings.ERRORSONLY_Option, string.Format("document: {0}\r\n", doc.Name));
string fName = wordFile.FullName.Replace(".docx", ".pdf");
fName = fName.Replace(".doc", ".pdf"); // incase document is from older version of word
object outputFileName = fName;
object fileFormat = wdInterpo.WdSaveFormat.wdFormatPDF;
// Save document into PDF Format
doc.SaveAs(ref outputFileName,
ref fileFormat, 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);
// Close the Word document, but leave the Word application open. // doc has to be cast to type _Document so that it will find the // correct Close method.
object saveChanges = wdInterpo.WdSaveOptions.wdDoNotSaveChanges;
((wdInterpo._Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
doc = null;
}
// word has to be cast to type _Application so that it will find // the correct Quit method.
((wdInterpo._Application)wdapp).Quit(ref oMissing, ref oMissing, ref oMissing);
wdapp = null; // com object must be destroy properly
}
catch (Exception ex)
{
wdapp = null; // com object must be destroy properly
EventTracer.Instance.Trace(Constants.TraceSettings.ERRORSONLY_Option, ex.ToString());
}
- the files on my folder are stuck up and most of the times pdf files in not sending through email
- Im getting the error above, I already adjusted the application
- On IIS its already application pool enable 32 bit = true and load profile enable = true
- Installed on my Nuget packages all are updated.
- DocumentFormat.OpenXml
- Microsoft.Office.Interop.Excel
- Microsoft.Office.Interop.Word
- Microsoft.SharePoint.Client
- PDFsharp