Sign in to follow this  
Bobs

[.net] STL Vector push_back crash during runtime

Recommended Posts

Hi, I'm using an unmanaged C++ library with in a Windows Forms Application in Visual C++ .NET 2003 with Managed Extensions. I'm getting a crash during runtime from my library code when I try to use the push_back method on an STL Vector object. I get the following error message: "An unhandled exception of type 'System.NullReferenceException' occurred in Library.exe Additional information: Object reference not set to an instance of an object." It crashes on line 516 in the STL Vector class file: size_type size() const { // return length of sequence return (_Myfirst == 0 ? 0 : _Mylast - _Myfirst); } Is there anyway around this crash? Any input may help.

Share this post


Link to post
Share on other sites
Problem is now fixed. I was trying to push_back to an STL vector of vectors at an index that wasn't yet created. After I created all my indexes I was able to successfully call push_back at a specific index (of vector type) in the STL vector. Your input encouraged me to look over my code. Thanks a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this