Fatal program exit requested

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
ptoon@einformatics.com
User
Posts: 10
Joined: Fri Mar 01, 2019 7:29 pm

Fatal program exit requested

Post by ptoon@einformatics.com »

I'm using the PDF Core API from the PRO SDK in C# and I've followed the core API sample for initializing the instance and closing it out, but I keep getting this unhandled exception from the .dll when exiting my application:

Unhandled exception at 0x6968A8D6 (PDFXCoreAPI.x86.dll) in TestDriver.exe: Fatal program exit requested.
The Common Language Runtime cannot stop at this exception. Common causes include: incorrect COM interop marshalling and memory corruption. To investigate further use native-only debugging.

Here is the snippet of code showing the initializing and closing of the instance:

Code: Select all

 PXC_Inst Inst = new PXC_Inst();
 Inst.Init(pdfKey);
 IPXC_Document doc = null;
 
 [doing work here]
 
doc.Close();
Inst.Finalize();
Inst = null;
GC.Collect();
GC.WaitForPendingFinalizers();
I've tried removing the GC components, I've tried removing the Finalize call.. and the program still throws this unhandled exception when closed.

Any assistance that can be provided would be extremely appreciated.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Fatal program exit requested

Post by Sasha - Tracker Dev Team »

Hello ptoon@einformatics.com,

Can you recreate this in the CoreAPIDemo application? Also, what thread apartment are you using?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
ptoon@einformatics.com
User
Posts: 10
Joined: Fri Mar 01, 2019 7:29 pm

Re: Fatal program exit requested

Post by ptoon@einformatics.com »

I'm not using any threading my code.

I am unable to reproduce this in the CoreAPIDemo application.

I did make a change to my code that seems to have made it go away though. I changed

Code: Select all

PXC_Inst Inst = new PXC_Inst();
To

Code: Select all

IPXC_Inst Inst = new PXC_Inst();
Would this make sense?

Thanks,
Phil
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Fatal program exit requested

Post by Sasha - Tracker Dev Team »

Hello ptoon@einformatics.com,

Technically that can be the case, as you need to create the IPXC_Inst interface.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
ptoon@einformatics.com
User
Posts: 10
Joined: Fri Mar 01, 2019 7:29 pm

Re: Fatal program exit requested

Post by ptoon@einformatics.com »

I actually need some further assistance with this. So let me explain exactly what I'm doing here. I've developed a dll that uses the PDFXCore.x86.API.dll to do some very specific functionality. The dll has two pretty simple methods in it which take in a document and then return some data based on the processing of the document. Not doing OCR or anything crazy, just scanning the form for certain fields/potentially adding a field and then returning some data about the form to the caller and the modified form.

The issue I'm running into here is that if I include the Garbage Collector call inside my method before returning a response to the caller, calling the method causes an unhandeled exception in PDFXCore.x86.API.dll. Here is a snippet of the code that causes that exception:

Code: Select all

IPXC_Inst ipxcInst = new PXC_Inst();
ipxcInst.Init(pdfKey);
IPXC_Document doc = null;

[do work]

doc.Close();
doc = null;
ipxcInst.Finalize();
ipxcInst = null;
GC.Collect();
GC.WaitForPendingFinalizers();
return something
Now if I take the GC call out and just leave everything else, the call to the method runs fine, but then the application consuming my DLL throws an unhandled exception when closing their app. Here is that code:

Code: Select all

IPXC_Inst ipxcInst = new PXC_Inst();
ipxcInst.Init(pdfKey);
IPXC_Document doc = null;

[do work]

doc.Close();
doc = null;
ipxcInst.Finalize();
ipxcInst = null;
return something
So either way, it seems that when the GC is getting called, the PDFXCore.API.x86.dll is throwing an unhandled exception, whether it's me calling it directly in my dll, or it getting called naturally when the calling application closed their app.

I know you asked the question before about if I could reproduce this in the Core API Demo app, and I cannot, but the major difference being that I'm on initiating the instance of the PXC_Inst when the method is called instead of with the opening and closing of a form. here are the lines from the demo app where it initiates the PXC_inst and then closes it, and I don't really see much difference:

Code: Select all

public PXC_Inst				m_pxcInst = null;
m_pxcInst = new PXC_Inst();
m_pxcInst.Init(m_sLicenseKey);
CloseDocument(); -- method call that just closes and nulls the IPXC_Document instance
m_pxcInst.Finalize();
m_pxcInst = null;
GC.Collect();
GC.WaitForPendingFinalizers();

I would really appreciate any assistance you can provide in finding a resolution to this. Happy to share whatever needs shared to help further the effort.

Thanks,
Phil
ptoon@einformatics.com
User
Posts: 10
Joined: Fri Mar 01, 2019 7:29 pm

Re: Fatal program exit requested

Post by ptoon@einformatics.com »

I seem to have resolved this. I've added several more Garbage Collectors to it, before the Finalize() and after another instance of IPXC_Image and IPXC_ContencCreator are both set to null and the exception seems to have gone away.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Fatal program exit requested

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply