Chapter 8. Calling Unmanaged Code

˜‚ˆ  ˜‚  


O BJECTIVES

This chapter covers the following Microsoft-specified objective for the "Creating and Managing Microsoft Windows Services, Serviced Components, .NET Remoting Objects, and XML Web Services" section of Exam 70-310, "Developing XML Web Services and Server Components with Microsoft Visual Basic .NET and the Microsoft .NET Framework":

Access unmanaged code from a Windows service, a serviced component, a .NET Remoting object, and an XML Web service.

  • Although the .NET Framework can handle nearly all your application development needs, most organizations have already accumulated a large amount of useful code before they begin using the .NET Framework. It doesn't make sense to simply throw away this legacy code and rewrite everything from scratch. Fortunately, if you've followed recommendations to encapsulate your code into components over the years , you don't need to abandon old code to start getting the benefits of the .NET Framework. Instead, you can make use of the .NET Framework's interoperability features to use the following types of legacy code in Windows services, serviced components, .NET remoting objects, and XML Web services:

    • Component Object Model (COM) components can be instantiated and invoked by .NET code.

    • The .NET platform invoke capability (usually referred to as PInvoke) can be used to call the Windows application programming interface (API).

    By using these interoperability features, you can ease your migration to .NET development. Making use of legacy components from .NET code means that you can migrate an application piece by piece rather than trying to do it all at once.

O UTLINE

Introduction

Using COM Components

Understanding Runtime Callable Wrappers

Building a COM DLL

Registering a COM DLL

Using the Type Library Importer Tool ( tlbimp.exe )

Using COM Components Directly

Using Platform Invoke

Chapter Summary

Apply Your Knowledge

S TUDY S TRATEGIES

  • If you have an existing COM object to work with, create a runtime callable wrapper for the object to investigate the conversion process. If you don't have any existing objects, you can build one with an older version of Visual Basic or Visual C++.

  • Experiment with PInvoke to invoke some common Windows API calls.


‚   ‚  
Top


MCAD. MCSD Training Guide (Exam 70-310. Developing XML Web Services and Server Components with Visual Basic. NET and the. NET Framework)
MCAD/MCSD Training Guide (70-310): Developing XML Web Services and Server Components with Visual Basic(R) .NET and the .NET Framework
ISBN: 0789728206
EAN: 2147483647
Year: 2002
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net