Page 1 of 1

Error compiling C# example under .NET Framework 4.0

Posted: Thu Dec 10, 2015 9:12 am
by comsa_se
Hello,

I'm currently evaluating your Driver API SDK V5 for creating PDF output from our ECAD application.
I have some problems compiling and running your C# example "PDFdriverAPI" in following environment:

- Windows 7 Pro
- Microsoft Visual Studio 2015 Express 2015 for Windows Desktop
- .NET Framework 4.0

Problem 1: Compiler error with framework 4.0:

At line 52: PDFPrinter = (PXCComLib5.CPXCPrinter)prnFactory.get_Printer("", "Simple PDF-XChange 2012", "<REG CODE>", "<DEV CODE>");
error CS0656: Missing compiler required member "Microsoft.CSharp.RuntimeBinder.Binder.Convert"

This compiler error is not raised under .NET 3.5 or below. But our application requires .NET 4.0.
Is this a known problem and if so can an update be expected in the near future?

Problem 2: "System.BadImageFormatException" with "Interop.PXCComLib5" when starting the app

When using a COM reference to "PDF-XChange Printer 2012 Type Library" in the project (as your example does) the generated Interop assembly "Interop.PXCComLib5.dll" has a size of 18 KB in contrast to 28 KB of your version of the same file which is delivered with your installed example. If I replace the COM reference with a direct assembly reference to your delivered version of "Interop.PXCComLib5.dll" the demo application runs fine under .NET 3.5 or below. (I yust copied "Interop.PXCComLib5.dll" into my bin\Debug folder with no additional files).

Do you have any idea why the COM reference creates this strange behaviour?

Thank you in advance,
Siegfried Eineder
COMSA GmbH

Re: Error compiling C# example under .NET Framework 4.0

Posted: Thu Dec 10, 2015 10:10 am
by Sasha - Tracker Dev Team
Hello comsa_se,

As for the problem 1, try this code:

Code: Select all

PXCComLib5.CPXCPrinter PDFPrinter = prnFactory.get_Printer("", "Simple PDF-XChange 2012", "<REG CODE>", "<DEV CODE>") as PXCComLib5.CPXCPrinter;
As for the second problem - we are investigating it and will give you an answer shortly.

HTH

Re: Error compiling C# example under .NET Framework 4.0

Posted: Thu Dec 10, 2015 3:17 pm
by Roman - Tracker Supp
Hello comsa_se,

As to the problem 2, please make sure it is not a deployment error.

Check if both the target assemblies (PDFdriverAPI.exe and Interop.PXCComLib5.dll) are compatible by "bitness".

You can verify this with CorFlags utility from your .Net framework SDK.
Both
CorFlags.exe PDFdriverAPI.exe
and
CorFlags.exe Interop.PXCComLib5.dll

should show the same CorFlags value.

Re: Error compiling C# example under .NET Framework 4.0

Posted: Thu Dec 10, 2015 8:02 pm
by comsa_se
Hello Sasha and Roman,

your hints perfectly solved my problems - thank you!
The demo program now works as expected and I'm starting to include PDF printing code into my applicationn.

Best regards,
Siegfried

Re: Error compiling C# example under .NET Framework 4.0

Posted: Thu Dec 10, 2015 8:10 pm
by Sasha - Tracker Dev Team
Glad to hear that :wink: