cancel
Showing results for 
Search instead for 
Did you mean: 

Start Unit using TestExecute Com on .Net project problem

Occasional Contributor

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 4
Community Hero

Re: Start Unit using TestExecute Com on .Net project problem

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.

Occasional Contributor

Re: Start Unit using TestExecute Com on .Net project problem

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

Community Hero

Re: Start Unit using TestExecute Com on .Net project problem

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.

Occasional Contributor

Re: Start Unit using TestExecute Com on .Net project problem

Actually I'm wondering about is my TE process really killed when I released the com object.
Even in my code, after releasing code I double check that is TE process still live by the code.

public void ForceQuit()
        {
            Process[] currentProcess = Process.GetProcessesByName("TestExecute");
            if (currentProcess.Any(x => x.ProcessName == "TestExecute"))
            {
                try
                {
                    Process.Start("taskkill", "/F /IM TestExecute.exe");

                    currentProcess = Process.GetProcessesByName("TestExecute");
                    while (currentProcess.Any(x => x.ProcessName == "TestExecute"))
                    {
                        currentProcess = Process.GetProcessesByName("TestExecute");
                        //Application.DoEvents();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception : {0}", ex.Message);
                }
            }
        }

As you mentioned above,  it may take more time to clear than the code is allowing, but by this code, it still has the problem.
Are there more processes do I have to wait to be killed except that TestExecute process?

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors