Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am dealing with similar issues at my work where my primary task is to write managed interfaces to certain high perfromance, low latency dlls, this involves simple cases where I have to wrap the native classes using simple c++/cli containing a raw pointer to the native class or more complex issues where the native code is a server side publisher and the managed code has to subscribe to it using delegates ie they have to be converted to native callbacks. .NET under the hood is a sophisticated COM server as far as I know. It is possible to write .net assemblies with the ComVisible attribute set to true then it acts as a classic COM component and then it is possible to use it from the native C++ code as a COM component. The reverse that is to use native code from managed can be achieved using the DllImport attributes and all the Marshaling can be fine tuned by the various attributes like the StructLayoutAttribute (<a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.structlayoutattribute.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.structlayoutattribute.aspx</a>) and the MarshalAsAttribute (<a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshalasattribute.aspx</a>) I am also using sometimes the unsafe keyword as well. I have to deal with high performance code so in some cases it is that after profiling that I know which is the best solution. Whether it is the warpper class solution that you have mentioned or the classic COM way, or some kind of hybrid with some caching, object pooling etc.</p> <p>Hope that helps. :)</p> <p>Apologies if that looks a bit disorganised. It is very late here. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload