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

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.

主站蜘蛛池模板: 朝阳区| 铁岭县| 张家港市| 扶余县| 仁化县| 通道| 浮山县| 嘉兴市| 绵竹市| 镇原县| 庄浪县| 五峰| 香港 | 武城县| 抚州市| 河北省| 万荣县| 柳林县| 屯门区| 上思县| 南宁市| 洪雅县| 阳江市| 周口市| 梅河口市| 晋中市| 山阳县| 山东省| 涿州市| 射洪县| 彭州市| 舒兰市| 青神县| 拜城县| 信丰县| 九龙县| 故城县| 汝阳县| 湄潭县| 皋兰县| 台中市|