Linking Rhino and static OpenNURBS library

Continuing the discussion from C++ linker warnings regarding ON_SimpleArray:

What I would like to ask is whether it is possible to have the following set up, where I have a native C++ DLL linked with a 3rd party meshing library and with the opensource OpenNURBS static library (built from code). This DLL exports a function for conversion to a different file format, which is performed by the third party meshing library.

Then, I create a C# plug-in that calls the C++ mesh export function using P/Invoke, marshalling a pointer to an ON_Mesh object. to the C++ side.

Is it possible to link on the one hand to the static OpenNURBS library, while receiving a pointer from Rhino to an ON_Mesh object that comes from the Rhino opennurbs_x64 shared library?

Small drawing:

======================================
C++ DLL exports function 
linked with 3rd-party mesh static lib
linked with OpenNURBS static lib
======================================
                 ^
                 |
======================================
C# Rhino Plug-in
Has a command that calls the
exported C++ DLL function by p/invoke
======================================
                 ^
                 |
======================================
Rhino: user issues command
Linked to opennurbs_x64.dll
======================================

Hi Menno,

The big problem here is which version of openNURBS new allocating and release memory. The version of openNURBS used by Rhino is not going to be using the same verison of onmalloc and onfree as the one you’ve statically linked into your DLL. Thus, when you pass a pointer from you DLL to Rhino/openNURBS, there is bound to be an issue when it comes time to releasing it.

I would think this would be better model:

======================================
Rhino-dependent C++ DLL exports function 
linked with 3rd-party mesh static lib
and opennurbs_x64.dll
======================================
                 ^
                 |
======================================
C# Rhino Plug-in
Has a command that calls the
exported C++ DLL function by p/invoke
======================================
                 ^
                 |
======================================
Rhino: user issues command
Linked to opennurbs_x64.dll
======================================