AfxGetThread returning NULL in Debug Mode and causing crash

A

Atul

I have a .Net Managed C++ wrapper control for a MFC control. When using the
..Net control in a Visual Studio 2005 Beta 2 C# project and running in Debug
mode, I get a crash saying something like "First Chance Exception : memory
cannot be read". I found that this was becuase a call to AfxGetThread() was
returning NULL. I tried using AFX_MANAGE_STATE(AfxGetStaticModuleState());
but it did not solve the problem.

Furthermore, this crash only occurs in Debug Mode and not in Release Mode.
Also, this occurs only in VS.Net 2005 Beta 2 and not in VS.Net 2003 ( either
release or debug)

How can this be resolved?
 

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