Interop

Interop PowerPoint PPT Presentation


  • 134 Views
  • Uploaded on
  • Presentation posted in: General

About Me

Download Presentation

Interop

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


1. .NET Interop Introduction to Managed/Unmanaged Code Interoperability

2. About Me… Ryan Beach GE Aviation Systems .NET for past 3 years

3. Agenda Purpose of Interop Calling legacy Application Programming Interfaces Passing user defined data types from Managed to Unmanaged code: marshalling COM

4. Purpose Ideally, all development should be ported over to managed code Realistically we need to be able to use legacy code with new managed code .NET allows for interoperation between managed and unmanaged code

5. Using unmanaged API’s PInvoke – Platform Invocation Services System.Runtime.InteropServices namespace Marshaling – Passing data between managed and unmanaged memory

6. Example of Using exported Unmanaged function from managed code Unmanaged function: C Header declaring the function below includes extern “C” __declspec(dllexport) Managed code:

7. Declaring function with a different name Why? Naming conflicts with other functions Naming conflicts with naming standards Multiple types of parameters can be used, so you want safety of different names to handle different types of data Example -

8. Calling Functions Dynamically Useful in calling loading an unmanaged dll that has some overhead that needs to be maintained throughout multiple function calls Example: Creating a database connection that needs to be maintained through multiple calls to a function to write to the database Code sample:

9. Blittable Data Types Data Types that don’t require conversion between unmanaged and managed code Reduces overhead

10. Marshalling Data Types

11. COM Good interoperability between .NET and COM

12. More Information .NET 2.0 Interoperability Recipes - Bruce Bukovics .NET and COM The Complete Interoperability Guide - Adam Nathan Slides and source code will be posted on www.frednug.org Contact me at [email protected]

  • Login