.Net Core 引用C++库,同时部署到Linux和Windows系统上

使用的是.Net 5.0:

部署到Windows上需要.dll库,部署到Linux上则需要.so库,所以在导入C++库的时候不能带扩展名,在lab文件夹中同时放入xxx.dll和xxx.so文件,导入如下:

[DllImport("xxx", CallingConvention = CallingConvention.Winapi)]
public static extern int Login(string username, string pwd,);
1
2
.net core 服务部署到Linux系统时还遇到了一个问题:
在表达路径的时候不能够使用双反斜杠"\",要用正斜杠"/",不然的话找不到对应的路径。

原文地址:https://www.cnblogs.com/cuigzh/p/15094921.html