Interop with Unmanaged Code – High Level View

The communication between the managed and the unmanaged world can be possible in two different models supported by .NET CLR

 

1)      Platform Invoke (Consuming unmanaged  DLL methods from managed code)

2)      COM Interop ( Exposing managed methods to unmanaged and vice versa using wrappers)

 

In my notes, I will focus more on the platform invoke which I used mostly.

 

Platform Invoke – This model involves invoking methods in an unmanaged DLL by creating equivalent managed prototypes. It then substitutes managed data types for unmanaged types and then marshalled across interop boundary when invoked.

 

COM Interop – This model is supported by some tools provided with .NET framework (tlbimp.exe and tlbexp.exe) which creates wrappers that perform the required marshalling between the managed and unmanaged world. Using this model, we can expose a managed library to unmanaged world and vice versa.

 

There can be detailed reading on this topic from msdn

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s