2 Replies Latest reply on Apr 21, 2015 2:49 PM by Greg Thomson

    Debugging Task Add-Ins

    Greg Thomson

      Does anyone know how to go about debugging a Task Add-In?  I'm not so sure the conventional Add Debug Add-In, Attach to Process work here, as the Task Add-in must be registered with the EPDM server, and most likely gets dispatched back to some other process (EdmServer.exe?).

       

      Any words of advice would be appreciated.

       

      2014 SP4

        • Re: Debugging Task Add-Ins
          Lee CS Young

          It depends on what portion of the task you're attempting to debug. If you're looking to debug the task setup in the Administration Tool, all you need to do is attach to the conisioadmin.exe process.

           

          To debug an executing task, it gets a little trickier. Load up your add-in as usual and select your machine to be the only machine that will execute the task. (In the task setup.) Close the administration tool. You'll need to create a symlink from the file in the plugins directory to your debug dll. I personally use DirLinker. The plugins directory is located at AppData\Local\SolidWorks\SolidWorks Enterprise PDM\Plugins\VaultName.

           

          In your sourcecode, place a messagebox.show in the OnCmd method and place a breakpoint at that line. Once the task loads up, the task will wait for the messagebox to be closed. When the messagebox is shown, you can attach to TaskExecutor.exe and then you'll be able to debug. If you're not hitting breakpoints, make sure you have the correct .NET framework version selected when debugging.

           

          If you're still not hitting breakpoints, EPDM probably loaded another instance of your dll into the plugins directory.

           

          That's the gist of it. Let me know if you have any questions.

          • Re: Debugging Task Add-Ins
            Greg Thomson

            Thanks Lee, this is a great synopsis of what has to be done.  Had to sort of muscle my way through it.

             

            All came together after I found this routine in the Sample Add-In and read a little further...

             

             

            private void PauseToAttachProcess(string callbackType)

            {

                try

              {

                   //If the debugger isn't already attached to a

                   //process,


                   if (!Debugger.IsAttached)

                   {

                       // Use a MsgBox dialog to pause execution and allow the user time to attach it...

                       MessageBox.Show("Attach debugger to process \"" + Process.GetCurrentProcess().ProcessName + "\" for callback \"" +            callbackType + "\" before clicking OK.");

                   }

               }

               catch (Exception ex)

               {

                       MessageBox.Show(ex.Message);

               }

            }