Hi,
I am trying to use COM object to create a MS Word (.doc/.docx) from a MS word template. (.dotx)
The code works perfectly from the AX rich client. However fails to execute from the EP.
I have generated the proxies etc...But not sure why the same piece of code gives error from EP.
I also tried to execute the same code from AX 2012 Batches and received the same error as that of EP, so not sure whats wrong in here?
Has anyone experienced this earlier?
Appreciate your inputs.
Error received:
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Method 'add' in COM object of class 'Documents' returned error code 0x800A141F (<unknown>) which means: Word was unable to read this document. It may be corrupt.
Try one or more of the following:
* Open and Repair the file.
* Open the file with the Text Recovery converter.
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Stack trace: Invalid attempt to call DocuActionArchive.Add running in CIL on the client.
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.
at Dynamics.Ax.Application.DocuActionArchive.Add(DocuRef _docuRef, String _filename, Boolean )
at Dynamics.Ax.Application.AVAInvoiceEngine.Ava_uploadinvoice(Int32 _refTableId, Int64 _refRecId, String _refCompanyId, String _name) in AVAInvoiceEngine.AVA_UploadInvoice.xpp:line 33
at Dynamics.Ax.Application.AVAInvoiceEngineBatch.Run() in AVAInvoiceEngineBatch.run.xpp:line 22
at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 54
at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13
at BatchRun::runJobStatic(Object[] )
at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
at BatchIL.taskThreadEntry(Object threadArg)
Code:
COM word;
COM documents;
COM document;
FileIOPermission filePermission;
//InteropPermission perm = new InteropPermission(InteropKind::ComInterop);
//perm.assert();
filePermission = new FileIOPermission(templatePath, 'rw');
filePermission.assert();
#define.Word('Word.Application')
word = new COM(#Word);
documents = word.documents();
document = documents.add(templatePath);