Hi,
I have voidmain() function in Program.cs
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmMain main = new frmMain();
MainTool.frmmain = main;
if (args != null && args.Length > 0)
{
Application.Run(new frmMain(args[0].ToString()));
}
else
{
Application.Run(main);
}
}
In that: MainTool.frmmain = main;
Assign frmmain variable of MainTool class (data processing class) with frmMain of Form Main.
The reason to do so is because I have a class data processing Excel file: MainTool.cs in the project declare frmmain variables for calling formMain.
The problem will not happen if I do not make the registration program on Windows Context Menu. To do that, I must take the path of the file into the program. Like this:
if (args != null && args.Length > 0)
{
Application.Run(new frmMain(args[0].ToString()));
}
else
{
Application.Run(main);
}
If so, I still miss main variables above. When you debug programs appear error: object reference not set to an instance of an object. Because not set args[0] for the main variables.
How to assign?
Thanks!