Readdy Write

C # Error: The runtime binding can not be executed for a NULL reference.

25.10.2018 (👁6202)


 

Error message:

The runtime binding can not be performed on a NULL reference.

 

C # Erroneous code

Excel.Range cell = usedRange.Cells[1, iColumn] as Excel.Range;

String sValue = cell.Value2.ToString();

 

In VSTO Addin, Excel:

When going through Excel cells.

 

Solution:

You have to convert with Convert.ToString (value_with_nulls)

String sValue = Convert.ToString(cell.Value2);

 

Complete error message in

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException

  HResult=0x80131500

  Message=Die Laufzeitbindung kann für einen NULL-Verweis nicht ausgeführt werden.

  Source=<Cannot evaluate the exception source>

  StackTrace:

<Cannot evaluate the exception stack trace>

 


0,00 €