NullReferenceException in calling C native method

P

Paul Brun

Hi guys,

I get the following error during runtime:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at SXInit(Int32 )

The SXInit method is a native C function I am calling from Managed C++ and the method is expecting a number of integers as
parameters and the constants I am passing have been defined in the C library as "#define xxxx 2100".

My questions are:

1) Why do I see Int32 there?

2) Are the "#define" statements converting themselves to Int32s?

I would appreciate if there is a way around calling C functions and passing them "int" according to the native data type definition
and not Int32 which is a C++ Managed Type since Int32 is an object.

Please let me know

Thanks
Paul
 
P

Paul Brun

just to clarify, this is the runtime definition in my "C" library header:

extern int SXInit (int, ...);

Paul

Hi guys,

I get the following error during runtime:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at SXInit(Int32 )

The SXInit method is a native C function I am calling from Managed C++ and the method is expecting a number of integers as
parameters and the constants I am passing have been defined in the C library as "#define xxxx 2100".

My questions are:

1) Why do I see Int32 there?

2) Are the "#define" statements converting themselves to Int32s?

I would appreciate if there is a way around calling C functions and passing them "int" according to the native data type definition
and not Int32 which is a C++ Managed Type since Int32 is an object.

Please let me know

Thanks
Paul
 

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

Top