Managed C++ Development
Paragraph.
Syntax Battles
Here are a few syntax helpers which help if your moving from c# to C++/CLI
Attributes
C#
[Editor(typeof(ObjectReferenceEditor), typeof(UITypeEditor))]
[TypeConverter(typeof(ObjectReferenceConverter))]
public struct ObjectReference
C++
[Editor(ObjectReferenceEditor::typeid, UITypeEditor::typeid),
TypeConverter(ObjectReferenceConverter::typeid)]
public ref class ObjectProxy
The Most Annoying Bug I've hit in C#
The other day I was working on an application that mixes C#, managed C++ and unmanaged C++. After linking in some of the static unmanaged libs into the project I hit this...
Everything compiled and linked fine with no warnings etc but when I ran the app it crashed/throws an exception here;
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
HERE-> Application.Run(new Form1());
}
The exception was as vague as one can possible be, trapping the exception and displaying the message etc didn't help.
First-chance exception at 0x7c812aeb in MyApp.exe: Microsoft C++ exception: HRException at memory location 0x0012dd04..
Turns out the static lib I'd linked to required a dll, that dll needs to be in the same folder as the .net application for it to find it or you get this exception.
Links
http://msdn.microsoft.com/en-us/library/b23b94s7(VS.80).aspx