Mixing managed C++ (CLR) and unmanaged C++


I’m trying to build a C++ plug-in for 64 bits. This plug-in contains some managed C++ code.

When I try to run its 64 bits version, I get the following message (approximately translated from french) …

The debugging managed assistant 'LoaderLock' has detected a problem in 'C:\Program Files\Rhinoceros 5.0 WIP (64-bit)\System\Rhino.exe'.
Additional informations : the DLL 'C:\Users\...\MyPlugin.rhp' attempts a managed execution in the lock of OS loader. Don't try to execute managed code in an init function or in DllMain, because it can block the application.

My plug-in project is configured with CLR support; by default, sources are compiled with /clr. Pure C++ sources are compiled without /clr (I set the property for each pure C++ source).

The 32 bits version of this plug-in runs successfully.

Do I need extra stuffs to mix managed and unmanaged C++ with Rhino 5 - 64 bits ?



it is in my experience not possible to have managed code in a c++ plugin because Rhino will attempt to load it as a .NET plug-in and fail to do so.

The plug-in actually loads successfully (even in 64 bits). The troubles come after the loading. The message I’ve quoted is popped when I quit Rhino.


Oh, sorry - my bad for not reading your message correctly. I never managed to load a mixed C++ plug-in into Rhino.

I don’t know about Rhino-specific issues, but have you read through the MSDN article about mixed assemblies and the loader lock?

Hi Jean,

Help me understand why you want to develop a mixed mode C++ plug-in for Rhino? Why not develop a true .NET plug-in, using either C# or Visual Basic, using RhinoCommon?

As a side note, none of the plug-ins shipped with Rhino are mixed-mode C++. If fact, I’ve never even tried to build this type of plug-in. It may be possible - I’m sure it’s painful.

Anyway, more information in what you are trying to do and why would be helpful.

– Dale

Hi Dale,

I must develop in C++ as I do an intensive use of C++ libs (mostly boost libs).
So, my choice would rather be to develop a true C++ plug-in.

The managed C++ code I have is only for GUI (dialog windows) as GUI development with MFC is really painful to me (especially for dynamic dialog windows).

I’m afraid I’ll have to migrate my GUIs to C++. Maybe using CRhinoUi* classes…


Well there is a much easier way to do this than using mixed mode C++. Its possible to developer UI in C# and call it from C++ - even Rhino does this. I’ll work up a sample you if you want.

I’d be interested in such a sample too. I’ve been struggling with this and may have a solution that is overly complicated. I’m curious to see how you guys do this :smile:

Yes, Dale.

If you could give an example of a C++ plug-in calling a C# UI, that would be great.


The recommended approach is to create your plug-in in C# and have the UI in your plug-in. The C# plug-in would then call into a C++ DLL library. Here’s a related port on the topic