T
Tony Johansson
Hi!
I have this simple main Console program. If I use row marked with 2 below it
work but if I use row marked 1 I get runtime exception saying COMException
was undandled. Exception HRESULT: OptionalParameter.
The reason for this it that I can't send null as parameter value to a COM
function.
I mean normally it would be perfectly legal to send null values instead of a
real object so why is it not valid in this case ?
class Program
{
private static Object OptionalParameter = Type.Missing;
static void Main(string[] args)
{
Application newExcelApp = new Application();
1 newExcelApp.Worksheets.Add(null, null, null,null);
2 newExcelApp.Worksheets.Add(OptionalParameter, OptionalParameter,
OptionalParameter, OptionalParameter);
}
}
//Tony
I have this simple main Console program. If I use row marked with 2 below it
work but if I use row marked 1 I get runtime exception saying COMException
was undandled. Exception HRESULT: OptionalParameter.
The reason for this it that I can't send null as parameter value to a COM
function.
I mean normally it would be perfectly legal to send null values instead of a
real object so why is it not valid in this case ?
class Program
{
private static Object OptionalParameter = Type.Missing;
static void Main(string[] args)
{
Application newExcelApp = new Application();
1 newExcelApp.Worksheets.Add(null, null, null,null);
2 newExcelApp.Worksheets.Add(OptionalParameter, OptionalParameter,
OptionalParameter, OptionalParameter);
}
}
//Tony