cd /root/dotnet/sdk
安装.net6.0sdk
# mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.110-linux-x64.tar.gz -C $HOME/dotnet
更改配置
vim /etc/profile
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
使更改的环境变量生效
source /etc/profile
查看安装的skd
dotnet --list-sdks
执行webApi服务
dotnet /filedisk/XW_CommSimSystem.Servic/XW_CommSimSystem.Service.dll
访问接口查看,测试显示成功
C++ so库调用
public static class LinkCal
{
public const string DLL = "libChannelModel.so";//"ChannelModelDLL.dll";//libChannelModel.so ChannelModelDLL.dll
[DllImport(DLL)]
public static extern int calDistance(Vector3D position, Vector3D targetPosition, out double dist);
}
如图,linux为 public const string DLL = "libChannelModel.so";
windows为 public const string DLL = "ChannelModelDLL.dll"
其他注意事项,如图,文件地址用反斜杠
后台运行,注意:必须cd到运行目录,否则会报各种各样的问题例如Connection id "0HMNJTC00CQVH", Request id "0HMNJTC00CQVH:0000007A": An unhandled exception was thrown by the application.......等报错
#进入程序目录m
cd /filedisk/XW_CommSimSystem.Service
#后台运行程序
dotnet XW_CommSimSystem.Service.dll &
查看所有进程
ps aux
关闭进程,kill 进程Id
kill 12720
后台启动
cd到目录下:
nohup dotnet XW_CommSimSystem.Service.dll &
查看进程
ps -ef | grep 程序名称## 或者ps -aux | grep 程序名称