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

R

Rob Van Zant

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=(sweep_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(UInt32 ) +0" for
malloc alternative].

Any help in resolving my problem will be greatly appreciated.

Thanks,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top