tailieunhanh - Calling C Library DLLs from C#
The .NET framework was designed to be the “lingua franca” for Windows development, with the expectation that it will set a new standard for building integrated software for Windows. However, it is inevitable that there is a time lag before .NET is fully adopted and existing applications are recoded. In particular, there is a large body of legacy code that will likely never be rewritten in .NET. To address this situation, Microsoft provides attributes, assembly, and marshaling. At the Numerical Algorithms Group (where I work), our particular interest in using these techniques is to utilize numerical software developed in C from within the .NET environment. Because. | Numerical Algorithms Group Title Calling C Library DLLs from C Utilizing legacy software Summary For those who need to utilize legacy software we provide techniques for calling unmanaged code written in C from C . The .NET framework was designed to be the lingua franca for Windows development with the expectation that it will set a new standard for building integrated software for Windows. However it is inevitable that there is a time lag before .NET is fully adopted and existing applications are recoded. In particular there is a large body of legacy code that will likely never be rewritten in .NET. To address this situation Microsoft provides attributes assembly and marshaling. At the Numerical Algorithms Group where I work our particular interest in using these techniques is to utilize numerical software developed in C from within the .NET environment. Because C is the premier .NET language the examples I present here are in C . While I use an example of data types that are current in the NAG C Library the techniques I present are general enough for calling unmanaged code written in C from C directly. The NAG C Library uses the following data types as parameters Scalars of type double int and Complex. These are passed either by value or by reference as pointers to the particular type . enum types. Arrays of type do uble int and Complex. A large number of structures generally passed as pointers. A few instance of arrays which are allocated within NAG routines and have to be freed by users these have type double . Function parameters also know as callbacks . These are pointers to functions with particular signatures. For convenience I include a C DLL containing definitions of all the functions being called from C . This DLL is available electronically from DDJ see Resource Center page 4 and NAG http public . For instance take the example of a C function that takes two parameters of the type double and double that is the first parameter is input
đang nạp các trang xem trước