D
Droopy
Hi,
I don't understand what's wrong with the following code.
It works in debug mode but generate a System.NullReferenceException in
release mode (see comment to locate the line where this exception
occurs).
I am using VS 2003, Win XP.
This class (SerialBuffer) is a managed C++ class developed to pass a char
buffer to unmanaged C++ legacy code in a mixed mode DLL.
This class is instantiated in C# code.
I made sample code here below to illustrate the problem (simplified as
much as I could).
// code.h
__gc public class SerialBuffer
{
private:
unsigned char __nogc *_buffer;
public:
SerialBuffer (short bufferNr);
~SerialBuffer ();
}
// code.cpp
SerialBuffer::SerialBuffer (short bufferNr)
{
_buffer = new unsigned char [16]; // this line fail in release
mode
}
SerialBuffer::~SerialBuffer ()
{
delete _buffer;
}
// win app code.cs
private void Form1_Load(object sender, System.EventArgs e)
{
SerialBuffer buf = new SerialBuffer (1);
}
Thanks in advance for your help,
Droopy.
I don't understand what's wrong with the following code.
It works in debug mode but generate a System.NullReferenceException in
release mode (see comment to locate the line where this exception
occurs).
I am using VS 2003, Win XP.
This class (SerialBuffer) is a managed C++ class developed to pass a char
buffer to unmanaged C++ legacy code in a mixed mode DLL.
This class is instantiated in C# code.
I made sample code here below to illustrate the problem (simplified as
much as I could).
// code.h
__gc public class SerialBuffer
{
private:
unsigned char __nogc *_buffer;
public:
SerialBuffer (short bufferNr);
~SerialBuffer ();
}
// code.cpp
SerialBuffer::SerialBuffer (short bufferNr)
{
_buffer = new unsigned char [16]; // this line fail in release
mode
}
SerialBuffer::~SerialBuffer ()
{
delete _buffer;
}
// win app code.cs
private void Form1_Load(object sender, System.EventArgs e)
{
SerialBuffer buf = new SerialBuffer (1);
}
Thanks in advance for your help,
Droopy.