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: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, 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 » Fri Mar 04, 2016 10:11 pm

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 133 times

Ivan - Tracker Software
Site Admin
Posts: 3591
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 » Mon Mar 07, 2016 5:53 pm

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 » Mon Mar 07, 2016 7:19 pm

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 » Mon Mar 07, 2016 8:04 pm

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.

Ivan - Tracker Software
Site Admin
Posts: 3591
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 » Tue Mar 08, 2016 7:43 pm

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 » Wed Mar 09, 2016 11:54 pm

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 » Mon Mar 14, 2016 5:05 pm

Any progress?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4089
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 » Tue Mar 15, 2016 7:17 am

Hello ewyuen2003,

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

HTH,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Wed Mar 16, 2016 4:37 pm

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,

User avatar
Sasha - Tracker Dev Team
User
Posts: 4089
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 » Thu Mar 17, 2016 7:32 am

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Tue Mar 22, 2016 10:56 pm

Ok. After changing to use IntPtr, 64-bit seems to work. Thank you.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4089
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 » Wed Mar 23, 2016 7:47 am

Hello ewyuen2003,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply