1. Trang chủ
  2. » Công Nghệ Thông Tin

net 2.0 interoperability recipes - a problem-solution approach (2006)

632 166 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 632
Dung lượng 1,94 MB

Nội dung

[...]... This allows you to validate the input value against a set of named values, eliminating the chance of passing an invalid magic number to the function You won’t have to wonder if a corporate customer is a type 2122 or a 2123, because you’ll have an enum type that defines the acceptable values Related Information See recipes 1-9 (Using C++ Interop As a Managed Wrapper) and 1-1 3 (Securing Access to Unmanaged... IJW It enables you to make calls to unmanaged code without the special function declarations or attributes required by PInvoke in other languages Interop marshaling (or just marshaling) is the process of passing data between managed and unmanaged memory during a call Marshaling takes place when input parameters are passed to an unmanaged function, and when a result is returned from the call Tasks performed... functions, change the calling convention and character set, handle errors and exceptions, and manage memory Chapter 2: C-Style APIs: Structures, Classes, and Arrays This chapter is a logical continuation of Chapter 1 and covers topics that relate to user-defined types such as structures and classes Recipes in this chapter cover passing structures, classes, and arrays between managed and unmanaged code; controlling... (GetCustomerStatus) doesn’t have any special memorymanagement requirements, but this won’t always be the case • A wrapper can include any amount of validation prior to calling the unmanaged function This is especially important when calling unmanaged functions that might be considered dangerous if passed incorrect values • A wrapper provides a place to check unmanaged return codes and translate these into... C-Style APIs P latform Invocation Services (PInvoke or P/Invoke) is the part of the common language runtime (CLR) that enables managed NET code to access unmanaged functions The functions can be written in ordinary C or C++, and they are usually packaged as dynamic link libraries (DLLs) These are the same unmanaged functions that you know and love, as they are routinely used by your non- .NET applications... services to NET Remoting and beyond He considers himself a pragmatic programmer He doesn’t stand on formality and doesn’t do things a certain way just because they have always been done that way He’s willing to look at alternate or unorthodox solutions to a problem if that’s what it takes Bruce is currently employed at Radiant Systems, Inc., in Alpharetta, Georgia, as a senior developer and architect... years Over the last quarter-century he has designed and developed applications in such widely varying areas as banking, corporate finance, credit card processing, payroll processing, and retail automation He has firsthand developer experience with C, C++, Delphi, Visual Basic, C#, and Java, and rode the waves of technology as they drifted from mainframe to client/server to n-tier, from COM to COM+, and... is declared, we can easily call it from our managed code as if it were just another static method in our class //make the unmanaged call int result = AddSomeNumbers(1, 2); Since we’ve declared this function as static within our managed code, we must call it as a member of the class rather than an object instance We don’t need to do anything special to translate the parameters or the return value between... you may be completely new to NET and are just learning the languages and class libraries associated with NET In either case, this book is for you Most of the examples in this book are presented in both C# and Visual Basic NET (VB .NET) You will be able to understand the examples as long as you know one of these languages But this book isn’t designed to teach you a language Likewise, you should already... between the managed and unmanaged code In this case, we’re dealing with only integers, which are represented the same way in both environments This won’t always be the case Related Information See recipes 1-1 (Identifying the Unmanaged Function), 1-4 (Changing the Calling Convention), and 1-5 (Renaming a Function) 1-3 Simplifying Reuse of Unmanaged Functions Problem You have an unmanaged function that must .

Ngày đăng: 26/10/2014, 20:42