Sometimes "Object reference not set to an instance of object
Posted: Thu Mar 30, 2017 12:29 pm
I created usercode that can be used in a recording; it works, but sometimes when I change one of the parameters I get an "unexpected error" and build error "Object reference not set to an instance of an object".
When I restart Ranorex it works again.
The code gets a date (f.e. $varBouwdatum or 01-01-2017), add days to it, and types the new date:
I'm pretty new at Ranorex / C#, so I hope someone can help me with that errors...!
When I restart Ranorex it works again.
The code gets a date (f.e. $varBouwdatum or 01-01-2017), add days to it, and types the new date:
Code: Select all
public static void addDays(string varDatum, int Days, Ranorex.Adapter K2WItem)
{
// string to datetime:
System.DateTime dt=System.DateTime.Parse(varDatum);
// add days:
dt = dt.AddDays(Days);
// datetime to string:
string dat = dt.ToString();
// type new date:
K2WItem.Click();
Keyboard.Press(dat);}