Home » excel » c# – Why do we specify the System.Reflection.Missing.Value?

c# – Why do we specify the System.Reflection.Missing.Value?

Posted by: admin May 14, 2020 Leave a comment


xlWorkBook.SaveAs(“C:\examples\employee.xls”, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

In the above relation why do we write most of the misvalue .
please explain,
Thanks in Advance

How to&Answers:

You are calling a COM component (Excel) using COM interop. COM is a totally different (and older) framework to .Net. To help you call the COM component, .Net creates a Runtime Callable Wrapper (RCW) which is a proxy class that allows you to use managed C# code to call COM. But C# and COM implementations of optional parameters are not compatible with each other–the C# compiler does not know how to map a default C# parameter onto a default COM parameter. Thus, for default COM parameters we have to explicitly give them the System.Reflection.Missing.Value.