Hi, I am trying to call a function before return an error but i got following error -An object reference is required for the non-static field, method, or property 'Psoft.Program.rea()' (CS0120) - C:\SVNviews\Automation\MainSolution\PUpgrade\Program.cs:43,12
namespace Test
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
return error;
}
}
}
Compile error
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: error handling
Hi,
The error state that you must first create an object instance before you can use a non-static field, method, or property. For you information please take a look at the following link: Compiler Error CS0120.
It would also be helpful if you could post the code which throws that error.
Regards,
Markus
Ranorex Support Team
The error state that you must first create an object instance before you can use a non-static field, method, or property. For you information please take a look at the following link: Compiler Error CS0120.
It would also be helpful if you could post the code which throws that error.
Regards,
Markus
Ranorex Support Team
Re: error handling
Thank you Markus for looking into it
Here is the code that throws an error
Here is the code that throws an error
Code: Select all
namespace PsoftUpgrade
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
ReadPlacementResultTable();
return error;
}
public void ReadPlacementResultTable() ///jjust for demo test
{
Console.Write("test");
Console.ReadLine();
}
}
}
Tipu
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Re: Compile error
Hello,
Try to define your method as static method:
Bernhard
Ranorex Support Team
Try to define your method as static method:
public static void ReadPlacementResultTable()Regards,
Bernhard
Ranorex Support Team