System.AccessViolationException

Class library usage, coding and language questions.
Michael
Posts: 1
Joined: Tue Jul 03, 2007 1:14 am

System.AccessViolationException

Post by Michael » Tue Jul 03, 2007 1:25 am

Hi,

I am getting a System.AccessViolation Exception when I load a particular form in my application. It is an MFC Based application and when I try to load the particular page or form I get the exception

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

After this the Test execution tool (we use NUnit) crashes.

The exception log gives the following details:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Ranorex.NativeMethods.RxFormGetFirstChild(Int32 handle)
at Ranorex.Form.GetControls()

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Tue Jul 03, 2007 7:17 am

Which Ranorex version do you use?
If V1.1.0 or earlier, then please update it to V1.2.0.
We fixed a similar bug in V1.2.0

You can read all controls in a form as follows (in V1.2.0):

Code: Select all

foreach (Control control in form.Controls)
{
    Console.WriteLine("Text= " + control.Text);
}
Jenö
Ranorex Team

jaco
Posts: 3
Joined: Fri Apr 03, 2009 1:11 pm

Post by jaco » Fri Apr 03, 2009 1:19 pm

Hi,

I get the same error as Michael. Our Ranorex version is 1.5.1.

System.AccessViolationException: Poging tot het lezen of schrijven van beveiligd geheugen. Dit duidt er vaak op dat ander geheugen is beschadigd.
bij Ranorex.NativeMethods.RxControlSendKeys(Int32 hWnd, String keys, Int32 pressDelay, Int32 downTime)
bij Ranorex.Control.SendKeys(String keys)

Sorry for the dutch part.

The SendKeys method is called from a wrapper I created, to set the text in a TextBox:

Mouse.ClickControl(textBox, MouseButtonType.LeftButton, new Point(-1, -1), 2, 100);
textBox.SendKeys(value);


Any ideas?

jaco
Posts: 3
Joined: Fri Apr 03, 2009 1:11 pm

Post by jaco » Fri Apr 03, 2009 1:30 pm

When I run the compiled executable, I get the error mentioned. When I run the testing code from Visual Studio, using ctrl-F5, I don't get the error.

jaco
Posts: 3
Joined: Fri Apr 03, 2009 1:11 pm

Post by jaco » Fri Apr 03, 2009 2:05 pm

Got it. The error message is a bit misleading. The error was caused by a missing value in my config file. I tried to read a user name from the config file, and set that user name in a text box. Instead of a null reference for the missing value, I got the AccesViolationException.