Saturday, November 20, 2010

An unsupported operation was attempted

I have puzzled by seeing the error message - "An unsupported operation was attempted", when I clicked on one of the MFC button control at run time.

After searching about this error in internet, I came to know that if one would have missed to remove the control variables and its dependent event handlers when he/she removed the control from the MFC dialog then he/she may experience this error message.

I feel, it is possible to detect this bug and throw appropriate (not the displayed one which I feel is misleading) warning/error message at build time itself, instead of throwing this error message at run time. If not at least the error message should be more appropriate. I don't know why this is not taken care by Microsoft, resource compiler (VC++ team)?

Monday, November 15, 2010

6 Things to note before you start debugging App in VS 2005

Often wondered why your application is not hitting up with break point when you try to debug it? OR wondered why the command line arguments you entered with VS IDE is not taken by your App? OR why your intended entry point is not hit by debugger (main/ winmain)?

If you wondered/puzzled by any of the above behavior then you MUST read this post! :)

Make sure the following things are set correctly before you start debugging your project in VS 2005:

1. If your project is among many many projects in a solution then make sure it is selected as "Set as start up project" by right clicking on the project

2. Select Linker->Subsystem as per your application's entry point function. For inst: it should be CONSOLE if your app is typical console app, /SUBSYSTEM:WINDOWS if your app is windows app

3. Set the required CL argument from Debugging->Command arguments

4. set C/C++->Optimization = Disabled

5. C/C++ -> Code Generation -> Runtime Library = Multi-threaded Debug (/MTd)or Multi-threaded Debug DLL (/MDd)

6. Linker->Debugging->Generate Debug Info = YES

A LNK2005 error...

The CRT libraries use weak external linkage for the new, delete, and DllMain functions. The MFC libraries also contain new, delete, and DllMain functions. These functions require the MFC libraries to be linked before the CRT library is linked.

http://stackoverflow.com/questions/1146338/error-lnk2005-new-and-delete-already-defined-in-libcmtd-libnew-obj

Sunday, May 2, 2010

My most referred technical books and resources

C programming language
The C Programming Language
-
K&R (Brian Kernighan and Dennis Ritchie)


// MSDN reference

C++ programming language

The C++ Programming Language -Bjarne Stroustrup

// MSDN reference
http://msdn.microsoft.com/en-us/library/3bstk3k5.aspx

// C++ FAQ community
http://parashift.com/c++-faq-lite/


Microsoft VC++ and MFC Programming

Programming Windows with MFC - Jeff Prosise

// MSDN reference
http://msdn.microsoft.com/en-us/library/d06h2x6e(v=VS.100).aspx

//Visual C++ Libraries Reference
http://msdn.microsoft.com/en-us/library/52cs05fz(v=VS.100).aspx