Ranorex.CommandFailedException / SerializationException

Class library usage, coding and language questions.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Ranorex.CommandFailedException / SerializationException

Post by jabelshauser » Thu Jun 25, 2009 3:56 pm

i have tried the version:

- ResetRanorexCore: after doing that, a FindForm-Command thows null-reference-exception. Are there constraints ?

- the Parent-Problem still occurs (also rarely)

what can i do else as workaround ?

regards jörg

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.CommandFailedException / SerializationException

Post by Support Team » Thu Jun 25, 2009 10:34 pm

Some additional thoughts:

1.
Please check the ApartmentState of the NUnit thread, it must be STA (Single Threaded Apartement). Usually, NUnit runs the testing thread with an MTA apartment state while Ranorex assumes STA (and requires STA).

An instruction on how to do that can be found here:
http://www.hedgate.net/articles/2007/01 ... unit-test/
The first option is to place a config file in the same directory as you NUnit test library DLL. The second option is to create a new thread with STA in every test method calling Ranorex.

2.
Is it possible to run the most important part of the test without NUnit (from the command line).
I would like to check whether the problem exists only within NUnit or not.

Jenö
Ranorex Team

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Re: Ranorex.CommandFailedException / SerializationException

Post by Skarlso » Mon Jun 29, 2009 9:55 am

Hello!

I have a solution for you...

I too have faced this problem when using nunit and DLL for execution and not EXE.

RanorexSpy is somehow locked up by nunit and that causes all your trouble.

The solution is more of a workaround then really a solution but at least it works.

One: Create Application Domains and put RAnorex into it.
Second this is more simple:

Create a plus Console Application that has the sole purpuse of executing a function that starts your respective test. And that Console Application will be started from your initial test.

So if you have a test like Calculator do the following.

Test: Press + Button.
[Test]
public void runTest( string someparameter)
{
Something.runTest( "PressPlusButton" );
}

This test is called by your Console Application which calls the respective test.
This way the Console Application will be between nunit and the Test. And after the test finishes it is no longer a problem because the EXE garbage collects the RanorexSpy properly. This way your long term test runs weill me no problem anymore.

Please ask away is something is unclear.
Gergely.

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: Ranorex.CommandFailedException / SerializationException

Post by jabelshauser » Tue Jun 30, 2009 9:53 am

Hello Skarlso

Thank you for your help, but the behaviour occurs also in an easy main-application (STAThread) without NUnit, so the proposed solutions shouldn't be successful.

best regards Jörg

Skarlso
Posts: 27
Joined: Thu Aug 07, 2008 9:11 am

Re: Ranorex.CommandFailedException / SerializationException

Post by Skarlso » Tue Jun 30, 2009 2:20 pm

Did you try it out? :)

It happened to me too. This helped. If it does not help you, you can still revert. :)

It isn't a hard work takes thirty minutes tops.

Np, hope it helps anyways.
Gergely.