PRB: System.NullReferenceException

  • Thread starter Thread starter ishekara
  • Start date Start date
I

ishekara

Hi,

Strange, I am having a .Net C++ managed dll project, where in i call a new
on a non managed code. This however is giving a problem,
I get an exception saying "An unhandled exception of type
'System.NullReferenceException' occured in Mydll.dll" "Additional
information: Object reference not set to an instance of an object",

class mycpp
{
}

__gc public class myclass
{
public:
myclass()
{
m_cpp=new m_cpp[10]; // this line gives me the error.
}
private:
mycpp *m_cpp;
}

However i have another test project where i wont get this error. Thats why i
called it as strange.

Please let me know if there is any workaround for this problem.

Thanks
IS.
 
Strange, I am having a .Net C++ managed dll project, where in i call a new
on a non managed code. This however is giving a problem,
I get an exception saying "An unhandled exception of type
'System.NullReferenceException' occured in Mydll.dll" "Additional
information: Object reference not set to an instance of an object",

The unmanaged heap is probably corrupted, and the call to new produces
an access violation exception. Try to test the application with PageHeap,
here is more information about it:
http://tinyurl.com/65xhd

Regards,
Oleg
 
ishekara said:
Hi,

Strange, I am having a .Net C++ managed dll project, where in i call a new
on a non managed code. This however is giving a problem,
I get an exception saying "An unhandled exception of type
'System.NullReferenceException' occured in Mydll.dll" "Additional
information: Object reference not set to an instance of an object",

class mycpp
{
}

__gc public class myclass
{
public:
myclass()
{
m_cpp=new m_cpp[10]; // this line gives me the error.
}
private:
mycpp *m_cpp;
}

However i have another test project where i wont get this error. Thats why
i
called it as strange.

Please let me know if there is any workaround for this problem.

Thanks
IS.

Could you post the real code, the snipet you posted doesn't even compile.

m_cpp=new m_cpp[10]; // THIS CANNOT compile

Willy.
 

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

Back
Top