Page 1 of 1

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

Posted: Fri Mar 04, 2016 10:11 pm
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.

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

Posted: Mon Mar 07, 2016 5:53 pm
by Ivan - Tracker Software
What platform target for your application? x86, x64 or AnyCPU ?

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

Posted: Mon Mar 07, 2016 7:19 pm
by ewyuen2003
I see the same problem if I target to x64 or AnyCPU. It is ok when it targets as x86.

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

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

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

Posted: Tue Mar 08, 2016 7:43 pm
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.

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

Posted: Wed Mar 09, 2016 11:54 pm
by ewyuen2003
Any good news?

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

Posted: Mon Mar 14, 2016 5:05 pm
by ewyuen2003
Any progress?

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

Posted: Tue Mar 15, 2016 7:17 am
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

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

Posted: Wed Mar 16, 2016 4:37 pm
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,

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

Posted: Thu Mar 17, 2016 7:32 am
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

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

Posted: Tue Mar 22, 2016 10:56 pm
by ewyuen2003
Ok. After changing to use IntPtr, 64-bit seems to work. Thank you.

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

Posted: Wed Mar 23, 2016 7:47 am
by Sasha - Tracker Dev Team
Hello ewyuen2003,

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

Cheers,
Alex