Creativity, Innovation... Failure



Notes : Programming in a managed and native environment

In this post I will be writting about calling managed code from native code.

The flag of compilation /clr:old_syntax does not support the use of specific .NET keywords (as #using).
Therefore, using /clr would be a workaround but is incompatible with flag /rtc1.

So I need a way to call managed code in a dll B from native code in a dll A.
To do so, no C++ managed extensions (C++/CLI) must be in dll A. Otherwise, it would need to be compiled with the flag /clr.

Solution is to put a native exported function (_declspec(export)) in dll B which returns an interface to my managed class. Then in my native dll A, I would simply include the header file to the exported function from managed dll B and call it to retrieve an interface which maps to the concrete managed class in dll B.

Hope this helps someone, if not feel free to ask questions.


Visual Studio 2005: Annoyance #1

We are all doing it!  We code then press 'F5' to test. But then on, especially when you are programming with C# you certainly use from time to time the 'Edit and Continue' feature. Right? I am but sometimes it gets annoying: upon pressing the pause button, you're always prompted to the main() function.

When using it extensively it turns out to be a pain in the ass ... Yell   So I decided to share how I resolved this issue.   First I took a look into the Tools>Options menu but found nada so I asked myself what can be done?   A MACRO!   So I simply had to find out how to break (1st line) and then how to prompt to the last document (2nd line).

Public Module RecordingModuleSub PAUSE_AND_CURRENT()
     DTE.Debugger.Break(True)
    
DTE.ExecuteCommand ("Window.NextDocumentWindowNav")
End Sub

So now we need this macro to be called when we pause.

  • Open up the "Macro explorer" from the Tools>Macro menu.

  • Create a macro and copy-paste the code above.

  • Save.

  • Go in the toolbar customization and a button with this macro.

  • Draw a nice icon for your button.

  • Enjoy!

If you know a better way let me know.


Visual Studio Debugger: Description of possible pointer values

Just wanted to share the description of some pointer values you may encounter while debugging in Visual Studio.

0xc0000005 - Access violation exception (http://www.updatexp.com/0xC0000005.html)
0xcccccccc - Uninitialized locals in Visual Studio 6 using flag /GZ
0xcdcdcdcd - Created but was not initialized yet
0xdddddddd - Deleted (Object created on stack but release because out of scope)
0xfeeefeee - Freed memory from heap manager (Ex.: mem_free was called)
0xabababab - Memory following a block allocated by LocalAlloc()

If you have any other values to share with us feel free to submit a comment with that value and description.