Menu

NullReferenceException: Debug vs. Run Mode

Help
wpilgri
2007-02-07
2013-04-22
  • wpilgri

    wpilgri - 2007-02-07

    I am new to Nini and am starting off with a simple test program in VS 2005 and C#.  I have an INI file that exists with the following info in it:

    [DAQConfigParameters]
        Ch4X2=0

    My simple program has the following code, but it keep throwing a NullReferenceException:

    IniConfigSource iCfg =
                    new IniConfigSource(@"C:\whatever\test.ini");
    iCfg.CaseSensitive = false;
    tmpStr = iCfg.Configs["DAQConfigParameters"].GetString("Ch4X2");

    tmpDbl = iCfg.Configs["DAQConfigParameters"].GetDouble("Ch4X2");

    Console.Out.WriteLine("Read {0:f1}",tmpDbl);

    For the life of me I cannot figure out why it is throwing a NullReferenceException.  I thought it was a case sensitive problem.

    Wait a minute.  Just before hitting send I did another test.  If I don't run in debug mode it works fine..no exceptions.  If I run in debug mode and put a breakpoint on the tmpStr and/or tmpDbl lines I get the exception thrown.  Any ideas why it would throw an exception in debug mode but not otherwise?

    Thank You

     
    • wpilgri

      wpilgri - 2007-02-07

      Did some more testing and the error seems to be in:

      System.NullReferenceException was unhandled
        Message="Object reference not set to an instance of an object."
        Source="Nini"
        StackTrace:
             at Nini.Ini.IniWriter.Dispose(Boolean disposing) in R:\Software Development\CSharp\Nini\Source\Ini\IniWriter.cs:line 211
             at Nini.Ini.IniWriter.Finalize() in R:\Software Development\CSharp\Nini\Source\Ini\IniWriter.cs:line 228

      I have to look at why it is trying to close an IniWriter when I didn't think I opened one.

      Very confused.

      Thanks Again

       
    • David McMinn

      David McMinn - 2008-02-15

      I'm in the same situation as you. Just started with Nini, using C# and MSVC 2005, and get a null object reference on program exit (Nini.Ini.IniWriter.Dispose) if I run in debug mode and place a breakpoint in the Nini using code somewhere. Debug mode with no breakpoints is OK. Release mode is OK.

       

Log in to post a comment.