PXCp_InsertPagesTo throws 'System.ExecutionEngineException'

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

costea
User
Posts: 14
Joined: Mon Sep 09, 2013 6:51 am

PXCp_InsertPagesTo throws 'System.ExecutionEngineException'

Post by costea »

Hello,

I am using PXCp_InsertPagesTo SDK PRO function to manipulate 2 pdf files. The system is Windows 7 on 32 bits. All functions such as PXCp_Init, PXCp_ReadDocumentW, PXCp_GetPagesCount works. But PXCp_InsertPagesTo throws 'System.ExecutionEngineException'. Also sometimes the PXCp_ReadDocumentW throws StackOverlfowException.

All needed libraries are loaded:
static XChangeInterop()
{
var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
path = Path.Combine(path, IntPtr.Size == 8 ? "x64" : "x86");

var dependency = Path.Combine(path, "dscrt40.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "xccdx40.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "ixclib40.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "pxclib40.dll");
NativeMethods.LoadLibrary(dependency);

dependency = Path.Combine(path, "fm40base.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "fm40tiff.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "netlib40.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "ocrtools.dll");
NativeMethods.LoadLibrary(dependency);
dependency = Path.Combine(path, "xcscan40.dll");
NativeMethods.LoadLibrary(dependency);

var file = Path.Combine(path, "xcpro40.dll");
NativeMethods.LoadLibrary(file);
file = Path.Combine(path, "pxcview.dll");
NativeMethods.LoadLibrary(file);
}

The function to call PXCp_InsertPagesTo is:
// Copy selected page ranges and insert them into destination PDF document
[DllImport("x64/xcpro40", CallingConvention = CallingConvention.Cdecl, EntryPoint = "PXCp_InsertPagesTo")]
private static extern int PXCp_InsertPagesTo64(IntPtr pSrcObject, IntPtr pDestObject, PXCp_CopyPageRange[] pPageRanges, int RangesCount, int Flags);
[DllImport("x86/xcpro40", CallingConvention = CallingConvention.Cdecl, EntryPoint = "PXCp_InsertPagesTo")]
private static extern int PXCp_InsertPagesTo32(IntPtr pSrcObject, IntPtr pDestObject, PXCp_CopyPageRange[] pPageRanges, int RangesCount, int Flags);

Please advise what to do to fix the problem.

Thank you
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3605
Joined: Thu Jul 08, 2004 10:36 pm

Re: PXCp_InsertPagesTo throws 'System.ExecutionEngineExcepti

Post by Ivan - Tracker Software »

Can you provide us a simple complete project where the problem reproduced?
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
costea
User
Posts: 14
Joined: Mon Sep 09, 2013 6:51 am

Re: PXCp_InsertPagesTo throws 'System.ExecutionEngineExcepti

Post by costea »

I have found the cause of the Exception. It is necessary to replace:
[DllImport("x64/xcpro40", CallingConvention = CallingConvention.Cdecl, EntryPoint = "PXCp_InsertPagesTo")]
private static extern int PXCp_InsertPagesTo64(IntPtr pSrcObject, IntPtr pDestObject, PXCp_CopyPageRange[] pPageRanges, int RangesCount, int Flags);
[DllImport("x86/xcpro40", CallingConvention = CallingConvention.Cdecl, EntryPoint = "PXCp_InsertPagesTo")]
private static extern int PXCp_InsertPagesTo32(IntPtr pSrcObject, IntPtr pDestObject, PXCp_CopyPageRange[] pPageRanges, int RangesCount, int Flags);

with

[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
LoadLibrary("xcpro40.dll");


[DllImport("xcpro40")]
public static extern int PXCp_InsertPagesTo(int pSrcObject, int pDestObject, PXCp_CopyPageRange[] pPageRanges, int RangesCount, int Flags);



The SDK PRO example containing PXCp_InsertPagesTo helped me to fix this issue on 32 bits.

Thank you
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19939
Joined: Mon Jan 12, 2009 8:07 am

Re: PXCp_InsertPagesTo throws 'System.ExecutionEngineExcepti

Post by Stefan - PDF-XChange »

Hi Costea,

Glad to hear the problem is resolved!

Regards,
Stefan