NullReferenceException: Object reference not set to an instance of an object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Van Zant

    NullReferenceException: Object reference not set to an instance of an object

    I have a 3rd party library (.lib) file with two header files which I have
    wrapped in a c++ .net dll. I am trying to use that dll in an asp.net
    project but I get the error "Object reference not set to an instance of an
    object."

    I added the dll to my project as a .net reference and I can see all exposed
    functions in the object browser. The function call(s) that causes the error
    is

    sweep_output_t* sweep_output = new sweep_output_t[sizof_series];
    [sweep_output=(s weep_output_t *)malloc(sizeof (sweep_output_t )*sizof_series) ;
    gives the same error.]

    sweep_output_t is a structure defined in one of the third party header files
    and sizof_series is an integer that in my test is set to 3. I don't know if
    it matters but I can not see sweep_output_t in the object browser but I can
    see sweep_output_s.

    typedef struct sweep_output_s
    {
    double f;
    double il;
    double rl;
    double ph;
    double gd;
    } sweep_output_t;

    I checked to make sure my dll is working correctly by changing the project
    to build an executable and adding a windows form and the lib file and
    wrapper code work great.

    The stack trace reveals "new(UInt32 ) +0" [or "malloc(UIn t32 ) +0" for
    malloc alternative].

    Any help in resolving my problem will be greatly appreciated.

    Thanks,
    Rob


Working...