4 Replies Latest reply on Mar 17, 2015 3:01 AM by Santosh Pawar

    Remote Procedure Call Failed

    Curtis Watson

      Hey guys,

       

      We've developed a system within our company's ERP system to interface with EPDM, load assemblies/parts into SolidWorks, find related drawings for all items in the BOM, find the related drawings and save them to PDF. This provides us up-to-date drawings for assemblies as the models are updated.

       

      The system has been in production for almost a year now with great success. Recently we have started experiencing issues with very specific parts - maybe one or two of the thousands and thousands of models in the EPDM system. The issue is repeatable with the given part numbers.

       

      Essentially the system operates as follows:

      1) Part number passed in.

      2) Look for .SLDASM, if not found then look for .SLDPRT, if not found then look for .SLDDRW - based on the part number passed in, we look for file matching that part number with different file types.

      3) If a .SLDASM or .SLDPRT is found, find the .SLDDRW for that part and save it as PDF on network drive.

      3a) For each item in the BOM (recursively),

      3aa) Get file information, check if already open in SW; if not already open, open it in SW.

      3ab) Find related drawing, open if not already open and save it as PDF on network drive.

       

      Essentially the system is failing when about halfway through a part's BOM - the last log message our system wrote is "Checking if file is already open within SolidWorks...". After we write this line into the log, we execute the following line of code. Please note that we write a log message immediately after this API call - this API call is the cause of the thrown exception.

       

      If solidWorks.GetOpenDocumentByName(file.Path) IsNot Nothing Then

          isFileOpen = True

      End If

       

      The 'solidWorks' variable is of type 'SolidWorks.Interop.sldworks.SldWorks' and through other logging, I have confirmed that the 'solidWorks' object is instantiated and that the 'file' variable is instantiated and that the 'file.Path' property is populated with a valid EPDM path.

       

      The exception being encountered is as follows - note the first item in the StackTrace is a SolidWorks API method (it is thrown from within the API and not from within my code):

      Exception encountered in EpdmService.GetBillOfMaterial().

      Exception.Message='The remote procedure call failed. (Exception from HRESULT: 0x800706BE)',

      Exception.StackTrace='

         at SolidWorks.Interop.sldworks.SldWorksClass.GetOpenDocumentByName(String DocumentName)

         at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, Boolean generateDrawings, Int32 version, String configuration, Decimal quantityMultiplier, SldWorks& solidWorks, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

         at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, Boolean generateDrawings, Int32 version, String configuration, Decimal quantityMultiplier, SldWorks& solidWorks, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

         at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, String partConfiguration, Boolean generateDrawings, Decimal quantityMultiplier, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

         at EpdmService.EpdmServiceLibrary.EpdmService.GetBillOfMaterial(String partNumber, String partConfiguration, Decimal quantity, Boolean generateDrawings, ServiceExecutionConfiguration serviceConfiguration, SalMessageForWebServiceCollection& messages, Boolean& wasExecutionSuccessful)'.

       

      Does anyone have some ideas as to what could be causing this? I've reviewed the event log on the server which hosts this system without finding anything further. Any ideas on how to debug what is going wrong in the API call or where I could look to find logs around what is going on?

        • Re: Remote Procedure Call Failed
          Jim Sculley

          The API docs for this method state the following:

           

          ==================

          Only call this method for a document that has already been opened in its own window. If you call this method for a document that has not been opened in its own window, then methods on the returned object may not work as expected.

          ==================

           

          In other words, if you aren't positive that the file has been opened in its own window, don't use it.  The call may not return 'null', but subsequent calls to the returned object may not behave as expected.

           

          For what it's worth, I have an add-in doing similar work here, and my code to see if a document is open looks like this:

           

                  /// <summary>
                  /// Compares the local path of the specified file to the paths of all documents open in
                  /// SolidWorks to determine if the file is open
                  /// </summary>
                  /// <param name="file">The file to check</param>
                  /// <returns><b>true</b> if the file is open in SolidWorks, <b>false</b> otherwise</returns>
                  public static bool isOpenInSolidWorks(IEdmFile5 file)
                  {
                      if (!solidworksIsRunning())
                      {
                          return false;
                      }
                      bool docFound = false;
                      object openDocs = getSolidWorks().GetDocuments();
                      if(openDocs == null)
                      {
                          return false;
                      }
                      foreach (object nextDocObj in openDocs as object[])
                      {
                          ModelDoc2 nextDoc = nextDocObj as ModelDoc2;
                          if (nextDoc.GetPathName().Equals(file.GetLocalPath(Utilities.getFileFolder(file).ID)))
                          {
                              docFound = true;
                              break;
                          }
                      }
                      return docFound;
                  }
          

           

           

          The GetDocuments() method will return all open documents, regardless of whether or not they are in their own window.

           

          Jim S.

            • Re: Remote Procedure Call Failed
              Curtis Watson

              Mr Sculley - thank you for catching that! I would have swore that the method was meant to check if the document was open or not - my mistake.

               

              I will give this a test run this week and mark your post as the answer if it resolves my issue. I have a good feeling you've found the problem, especially since it looks like you've experienced this before (sorry my bug is contagious lol).

            • Re: Remote Procedure Call Failed
              Jim Sculley

              Thanks alot Curtis.  It's contagious.  I just received this email from my error handler code:

               

              User

              B WALKER

              Date/Time

              3/16/2015 3:25:57 PM

              Message

              The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

              File

              1. 426805.SLDDRW

              Stack Trace

              at SldWorks.ISldWorks.QuitDoc(String Name) at com.azz.wsi.epdm.release.PDFGenerator.generateSolidWorksPDF(IEdmFile5 drawingFile, IEdmFolder5 destinationFolder) at com.azz.wsi.epdm.release.SWDrawingPostStateFileHandler.publishApprovedDrawing() at com.azz.wsi.epdm.release.SWDrawingPostStateFileHandler.handlePublishing() at com.azzwsi.epdm.release.SWDrawingPostStateFileHandler.handle()

               

              All kidding aside, I've seen this one before.  No pattern to when or how it occurs.  It just does.

               

              Jim S.