System.AccessViolationException : Automation API

System.AccessViolationException

Class library usage, coding and language questions.

System.AccessViolationException

Postby Michael » Tue Jul 03, 2007 2: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()
Michael
 
Posts: 1
Joined: Tue Jul 03, 2007 2:14 am

Postby admin » Tue Jul 03, 2007 8: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
admin
Site Admin
 
Posts: 351
Joined: Wed Jul 05, 2006 8:44 pm

Postby jaco » Fri Apr 03, 2009 2: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 2:11 pm

Postby jaco » Fri Apr 03, 2009 2: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 2:11 pm

Postby jaco » Fri Apr 03, 2009 3: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.
jaco
 
Posts: 3
Joined: Fri Apr 03, 2009 2:11 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests