在unity中我使用了c#的系统函数,System.Threading.Mutex 这个函数
在Windows上进行跨进程通信,需要读取一个互斥量,观察unity运行的TCP服务器有没有正常启动
这时使用IL2CPP的方式进行编译发布,发现运行时在如下行出现异常:
mutex = new System.Threading.Mutex(true, "test_mutex", out have);
使用try,catch捕获异常,显示函数调用异常,也就是找不到函数的实现。
通过查看IL2CPP编译之后的C++源码发现,函数实现出现问题,并未转换成功
具体代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestMutex : MonoBehaviour
{
// Start is called before the first frame update
System.Threading.Mutex mutex;
void Start()
{
CreateMutex();
ReleaseMutex();
CloseMutex();
}
// 创建互斥量
public void CreateMutex()
{
bool have = false;
mutex = new System.Threading.Mutex(true, "tes