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

  • .NET Core 2.0 By Example
  • Rishabh Verma Neha Shrivastava
  • 222字
  • 2021-06-24 18:31:02

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.

主站蜘蛛池模板: 乳山市| 漳平市| 高州市| 定陶县| 盱眙县| 贵州省| 鱼台县| 金寨县| 吉木萨尔县| 财经| 淮南市| 双辽市| 息烽县| 门源| 宜黄县| 柘城县| 阿坝| 合肥市| 景洪市| 柞水县| 和顺县| 双辽市| 句容市| 乌兰察布市| 成武县| 泽州县| 延寿县| 连城县| 万荣县| 新营市| 米泉市| 扎囊县| 大埔县| 绥中县| 合水县| 隆安县| 平泉县| 阿合奇县| 辛集市| 鲁山县| 平远县|