OleInitialize fails when enabling Common Lanuage Runtime?

I am working on a wxWidgets console application that I want to call in = C # DLL, via CLR. Unfortunately, the app is hiccuping in the initialization code of the wxWidgets app because OleInitialize doesn't work. The error I see is a popup simply stating "Unable to initialize OLE".

This issue seems to be usually avoided by setting the flat style for threads, applying the directive to the application's entry point, but I'm really struggling with the entry point I'm looking for. My C # code is DLL: no specific entry point. The code compiled with / CLR exists in the .lib which is linked to my wxWidgets app. wxWidgets actually defines WinMain in its code and allows me to override the behavior through the wxApp implementation.

Other suggestions include disabling OLE support in wxWidgets, but in my version 2.8.6 setting it wxUSE_OLE, wxUSE_CLIPBOARD, wxUSE_DATAOBJ, wxUSE_DRAG_AND_DROP

to 0 creates unresolved external values ​​when compiling wxWidgets.

Enjoyed this before and found an effective job? Can anyone please clarify which entry point I need to change?

+2


source to share


1 answer


As mentioned in my question, this is an issue related to the flow style settings between the C ++ application and the CLR defaults. Apparently this was a bug and Microsoft released a fix:

http://msdn.microsoft.com/en-us/library/s6bz81ya.aspx



Re-compiling the executable uses CLR-enabled.lib with / CLRTHREADATTRIBUTE: STA was enough to fix the errors I saw.

+1


source







All Articles