[RESOLVED] Object reference not set to an instance of an object.
Hi, I am stuck here. The code is pretty straightforward.
Code:
string str1=null;
string str2=null;
int rCnt = 0;
for (rCnt = 2; rCnt <= nRows; rCnt++)
{
foreach (KeyValuePair<int, List<int>> pair in dict)
{
List<int> list = new List<int>();
list = pair.Value;
string colName = GetExcelColumnName(list[0]);
string col = colName + rCnt .ToString ();
str1 = xlWorkSheet1.get_Range(col, misValue).Value2.ToString();
After I step into the last line I got an error
Code:
Object reference not set to an instance of an object.
But I checked it in the immediate window
Code:
?xlWorkSheet1.get_Range(col, misValue).Value2.ToString()
It is okay although the value is null but no error.
Thanks for advice.
Re: Object reference not set to an instance of an object.
I don't see a definition for misValue anywhere. How is that defined?
-Max
Re: Object reference not set to an instance of an object.
It was defined as
Code:
misValue = System.Reflection.Missing.Value;
I still got error even I redifine it in the scope.