Reputation: 31
This is the first time I have ever used a site like this, but I am significantly stuck. The background section that follows is included for completeness as I am not sure if any of the actions described within it may have contributed to the current problem I am facing.
Background
A colleague and I had written a whole lot of c++ code in a console application (with default settings) in visual studio 2010 (full version) for a university assignment. We decided that we wanted to try our hand at a winforms application and so created one in visual studio 2010 and imported all our code from the console application. We faced the following issues:
After we had done the above things our project was compiling.
The Problem
When we run the application we get the following assertion failure:
_CrtIsValidHeapPointer(pUserData)
This assertion fails immediately, seemingly without any code being executed, as when I set breakpoints at the start of main they are not reached in debugging (call stack is empty).
The only way I have been able to get the application to run is by setting the CLR option to /clr:pure and removing all usage of boost.
I have 3 questions:
Thank you all for your time, I have not posted any code because I literally don't know what to post...I have no idea where the issue is occurring. If anyone has suggestions for what code to post, I am open to them.
Regards Brad
Upvotes: 3
Views: 1563
Reputation: 2061
I know it's quite late, but I found this question because I had the same problem.
Looking in another project I've working (not mine), I've found that the problem comes from the file: opencv_ts248d.lib
. If you delete it from your depencencies, it'll work fine (I don't know why, guess the problem is in a function which belongs to it), so you'll have the following ones:
opencv_calib3d248d.lib
opencv_contrib248d.lib
opencv_core248d.lib
opencv_features2d248d.lib
opencv_flann248d.lib
opencv_gpu248d.lib
opencv_highgui248d.lib
opencv_imgproc248d.lib
opencv_legacy248d.lib
opencv_ml248d.lib
opencv_nonfree248d.lib
opencv_objdetect248d.lib
opencv_ocl248d.lib
opencv_photo248d.lib
opencv_stitching248d.lib
opencv_superres248d.lib
opencv_video248d.lib
opencv_videostab248d.lib
(I'm just including all them without focusing in what I need, except the one which results in the problem)
Hope it helps you
Upvotes: 0
Reputation: 6204
To try and answer your specific questions:
main()
is the entry point to your code and not the entire executable. There may be a large amount of boilerplate initialization as well as initializing all global static objects. For example, in the follow example the the function is run before main is entered:
int SomeGlobal = SomeFunction();
int main (void)
{
...
}
I have near zero experience with /clr but I can point you at a few useful references. Make sure you understand everything that applies to you in How To Migrate to /clr and the /clr settings.
I again have no direct knowledge but this forum post on boost::shared_ptr and this SO question on boost::thread seem to indicate there are some issues.
To further diagnose the issue I would try a few things:
pUserData
may be from a CString destructor. Make sure all strings are migrated to managed system strings.Upvotes: 1