PDF Tools sample crashes vshost.exe when build for .NET 4.0

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: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

PDF Tools sample crashes vshost.exe when build for .NET 4.0

Post by ewyuen2003 »

My OS version is Windows 7 - 64bit.
I try to compile the sample C# app PDFXCDemo. The app runs if it is compiled with .NET 2.0 and debug ok in Viisual Studio. If I set my target to .NET 4 or above (e.g. .NET 4.5.1), visual studio vshost.exe crashes (see attached.)
The application runs if I run the application outside visual studio,
I am using VS2015.
Attachments
vshost.zip
Vshost crashed
(9.37 KiB) Downloaded 334 times
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by Ivan - Tracker Software »

What platform target for your application? x86, x64 or AnyCPU ?
Tracker Software (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.
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

I see the same problem if I target to x64 or AnyCPU. It is ok when it targets as x86.
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

Please also note that when we install VS2015. .NET 4.6 is installed. Therefore, we are using .NET4.6 CLR to run code in .NET 4.5.1 codes. .NET 4.0+ always replace the CLR to achieve backward compatibility.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by Ivan - Tracker Software »

I have suspicion that in functions declaration wrong type is used for document representation - it should be type that is 32-bit for 32-bits configurations and 64-bits for 64-bits.
I will check and come back.
Tracker Software (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.
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

Any good news?
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

Any progress?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by Sasha - Tracker Dev Team »

Hello ewyuen2003,

Please check here and update your correspondent file with this one:
https://gist.github.com/socrat74/74bd575fe728a543de4d

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

Your new PDFXC_Funcs file changed the signature of many API. e.g.

public static extern int PXC_AddPage(int pdf, double width, double height, out int page);

to

public static extern int PXC_AddPage(IntPtr pdf, double width, double height, out IntPtr page);

So the original sample applications do not compile.

Do you have an updated sample application which I can use to test?

I originally tested with

PDF-Tools 4 SDK\Examples\SDKExamples\C#Examples\PDXCDemo

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

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by Sasha - Tracker Dev Team »

Hello ewyuen2003,

You must change the corresponding method usage with correct variables. As we described previously the int type was used as pointer type and in x86 it worked properly. But in x64 the high part of the pointer is being "eaten" because of the int type, thus the pointer only had it's low part which led to the unknown consequences. The IntPtr type is working correctly for both x86 and x64 architecture types.

HTH,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
ewyuen2003
User
Posts: 7
Joined: Fri Mar 04, 2016 10:04 pm

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by ewyuen2003 »

Ok. After changing to use IntPtr, 64-bit seems to work. Thank you.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: PDF Tools sample crashes vshost.exe when build for .NET

Post by Sasha - Tracker Dev Team »

Hello ewyuen2003,

Glad that worked for you, we'll mark this topic as closed.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply