7 Replies Latest reply on Jul 5, 2017 9:17 AM by Jason Meech

    SetPageSetupOptions Error

    Ross K.

      Hi,
      I have a C# WPF application which was using an older 32-bit version of the eDrawings EModelView DLL. I have upgraded this to the latest 64-bit version by following the guidance online. Part of the application allows the user to print out a specific drawing without showing any dialog box. This used to work OK but since upgrading I now get a full program crash when I use the SetPageSetupOptions function. If I comment out this line and set the Print5 command to show the print dialog box, it does work.

       

      The application is intended to be run on a touch-screen kiosk so I really want it to work as it did before ... Is this an issue with the latest version or is there something I am not doing correctly which I was getting away with before? Other than the Printing, everything else seems ok

       

      SolidWksVwrCntrl.eDrawingsControl.SetPageSetupOptions(EModelView.EMVPrintOrientation.eLandscape, (int)System.Drawing.Printing.PaperKind.A4, 0, 0, 1, (int)System.Drawing.Printing.PaperSourceKind.AutomaticFeed, strPrinterName, 0, 0, 0, 0);

      SolidWksVwrCntrl.eDrawingsControl.Print5(true, strFilename, false, false, false, EModelView.EMVPrintType.eScaleToFit, 1, 0, 0, true, 1, 1, "");

        • Re: SetPageSetupOptions Error
          Peter Brinkhuis

          You could at least add a try catch block around that line to prevent it from crashing. I checked out the function in the help but didn't see anything wrong with it at first sight. Have you checked the three references by adding them manually again? Maybe they don't exist anymore. Try replacing them with the integer value to see if that gives the same crash.

            • Re: SetPageSetupOptions Error
              Ross K.

              Thanks for the reply. Sorry the code I have given is only a snippet but I have indeed added a try catch block around it which unfortunately is not hit. I just get a full crash and a vshost.exe has stopped working message box.

              I have tried changing the enum values to their integer equivalents yet the problem persists

            • Re: SetPageSetupOptions Error
              Jason Meech

              We reported this through our VAR with the same issue and they created an SPR.  It's been a bug since Solidworks/eDrawings 2016.  It's halted our company from upgrading Solidworks since we have numerous automated processes that print/PDF using eDrawings.

               

              SPR# 995209

              • Re: SetPageSetupOptions Error
                Jason Meech

                I've asked our VAR to follow up with Solidworks again.  I think I've narrowed it down what the root cause is and provided further insight to them.  This does work properly on Windows 7 (64 bit).  What I've determined is the standard form names in Windows 8(?) and up have technically changed.  I'm unclear why Microsoft would have thought to do that.  The second parameter in the SetPageSetupOptions is accepting a value for the page size.  While it may be being set via your code correctly, I'm guessing their calls/lookups aren't finding it correctly on the OS because of this change.

                 

                I've attached a screenshot of what I think is somehow linked to the problem which is buried within their code.  The left picture is of Windows 10 form names.  The right picture is of Windows 7 form names.  You'll notice Windows 10 uses a multiplication symbol, while Windows 7 uses the letter X.  I came across another development tool we use that wasn't working on Windows 7 (I'm using Windows 10 development box) and had the same issue.

                 

                I hope someone form Solidworks is monitoring the forums to get this bug finally fixed.

                 

                Standard Form Sizes.JPG

                  • Re: SetPageSetupOptions Error
                    Ivana Kolin

                    If this crash is caused by missing or wrong form name, can you create a new form with proper name to solve it?

                      • Re: SetPageSetupOptions Error
                        Jason Meech

                        The parameter is for paper size and is a .NET constant (PaperKind Enumeration (System.Drawing.Printing)  We don't actually specify the form name.  I'm just guessing it has to do with the standard form name changes in Windows.  eDrawings 2016 and higher has this issue - 2015 works fine.  Something changed in the eDrawings application along the way and I am guessing it might be trying to lookup form names and not realize the standard names have actually changed.  We'll never get a peak inside the black box, so I can only speculate.

                         

                        I tried specifying a custom paper size in Windows 10 and the SetPageSetupOptions call still crashes.

                         

                        I do appreciate your suggestion.  I'll update this post when we hear back from our VAR on an estimated date of resolution to the case.

                    • Re: SetPageSetupOptions Error
                      Jason Meech

                      Finally heard back from Solidworks.  They claim this is fixed in 2018 b2 and future releases.