Forum Discussion

anna_gl's avatar
anna_gl
Occasional Contributor
6 years ago

Start Unit using TestExecute Com on .Net project problem

I'm developing .Net Program with TestExecute. I followed the direction in document "Calling Script Routines via COM"
(https://support.smartbear.com/testexecute/docs/running/automating/com/calling-script-routines.html).

 

In my code when user start(nobody knows when user start the project), then TE process should be run.

After that task finished TE should quit the process, and when another signal(start signal, also don't know when it will be) come, then TE process should start again.

So in .Net code I released the com object after routine finished, and when another signal come,(.net project doesn't finish, it runs until the final 'exit' signal comes) I recreate the com object via method(Activator.CreateInstance()).

But the TE is freezed when recreated. (when new created Process launched with unit, it stucks with indicator status "Playback" endlessly.)

And "Playback" indicator didn't dissapear until I quit the process on "Window Process Manager".

 

Is this problem realated the ccw life cycle? 

I can't get why TestExecute stops. 

Please help.

4 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Tell us what version of TestComplete and what version of TestExecute you are running.

     

    It would also be helpful to see your code.  The more details we have, the easier it is for us to help you.

    • anna_gl's avatar
      anna_gl
      Occasional Contributor

      My TC and TE are both v.14. I upgraded both tools several days ago. 

      But before upgrade, when tools were v.12, same problem was there.

       

      Here are my .Net codes.

      public bool ConnectComObject()
              {
                  try
                  {
                      TestExecuteObject = Marshal.GetActiveObject(TEProgID);
                  }
                  catch (Exception ex)
                  {
                      try
                      {
                          TestExecuteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TEProgID));
                      }
                      catch (Exception e)
                      {
                          Application.DoEvents();
                      }
                  }
      
                  if (TestExecuteObject == null)
                  {
                      return false;
                  }
                  TestExecuteManager = (ITestCompleteCOMManager)TestExecuteObject;
                  IntegrationObject = TestExecuteManager.Integration;
                  
                  Application.DoEvents();
                  return true;
              }

      First of the process, I call this method for start TE.

       

      And call next code(it's a key part of full method), the variables such as 'param', 'projectName', 'unitName' are all has right value.(before this code I did validate variables value)

      if (param == null)
                      {
                          IntegrationObject.RunRoutine(projectName, unitName, "Run");
                      }
                      else
                      {
                          IntegrationObject.RunRoutineEx(projectName, unitName, "Run", param.ToArray());
                      }

      When all unit process finished, I release the com object.

      public bool DisconnectCom()
              {
                  
                  try
                  {
                      TestExecuteManager.Quit();
                      var releaseResult = Marshal.ReleaseComObject(IntegrationObject);
                      IntegrationObject = null;
                      releaseResult = Marshal.ReleaseComObject(TestExecuteManager);
                      TestExecuteManager = null;
                      releaseResult = Marshal.ReleaseComObject(TestExecuteObject);
                      TestExecuteObject = null;
      
                      GC.Collect();
                      GC.WaitForPendingFinalizers();
                      GC.Collect();
                      GC.WaitForPendingFinalizers();
      
                  }
                  catch (Exception ex)
                  {
                      logger.Info("Exception  : {0}", ex.Message);
                      return false;
                  }
                  return true;
              }

       

      The problem is that the next time I recall the first code(top code of here).

      .Net project still run, and I have to recreate the TE process for next step.

      Then the TE proccess created on windeow session but it becomes freeze status with indicator "Playback".

      That indicator hang endlessly until manuallly kill the process.

       

      I have to quit the process and restart it during the .Net program.

      But I can't get any clue of this problem. 

      Once I thought it is related with rcw or ccw(it might be ccw..), but I don't know how control the ccw so please help me.

       

      What I found out about ccw : https://docs.microsoft.com/en-us/dotnet/framework/interop/com-callable-wrapper

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        Are you sure that it's actually released after the first time through?  It may take more time to clear than the code is allowing.