官术网_书友最值得收藏!

Interop with existing native and Mono libraries

Code reusability is one of the key principles in programming. For example, in an application we may use a certain functionality multiple times, so we keep it in a useful place and refer it from that place, whenever we need it in our application. Now, suppose our application implemented some common functionality which we can use in other applications, in this case, instead of writing the same logic again, we can create a library. It is easily distributable and reusable.

Asp.NET Core supports cross-platform programming, so any Linux user who has built many reusable libraries, API-like console support, and filesystem access, and wants to use them while writing code in ASP.NET Core, can access them. In this section, we will see how to access these native libraries (.dll) and Mono libraries (.so) in the program.

Common Language Infrastructure (CLI) helps to interoperate with existing code. We need to handle three basic problems to get things to work. First, where and how to specify the library, second, determining which function we want to invoke, and third, passing parameters. Common Language Runtime (CLR) provides Platform Invocation services—we call it P/Invoke. It enables managed code to call C, C++ functions in native libraries (DLLs). Let's discuss what Platform Invoke is and how to use it.

主站蜘蛛池模板: 绥阳县| 绍兴市| 土默特左旗| 时尚| 怀来县| 鄂尔多斯市| 开远市| 丹巴县| 丰县| 赞皇县| 五华县| 双峰县| 五大连池市| 新泰市| 若尔盖县| 开阳县| 凤翔县| 通渭县| 格尔木市| 古田县| 永泰县| 金坛市| 邵东县| 安乡县| 油尖旺区| 山阳县| 芜湖市| 嘉禾县| 桑植县| 准格尔旗| 泸州市| 布尔津县| 达拉特旗| 阿克苏市| 根河市| 上蔡县| 桂阳县| 望谟县| 金川县| 闸北区| 岢岚县|