Strangely enough, my code passed tests and it failed when deployed to another computer. It makes no difference if the pc that passes the test has an operating system of win10 Enterprise Edition and the test fails for Win10 Home Edition. The failure phenomenon is very confusing, the Visible = 1 assignment does not work, the value of this property is always 0, the interface has not yet been displayed, but the process has Rhino .exe, and there is no other error message
Console.WriteLine("准备启动测试");
commitUrl = args.FirstOrDefault() ?? "未提供";
// Try creating an instance of Rhino
const string rhino_id = "Rhino.Application";
var type = Type.GetTypeFromProgID(rhino_id);
Console.WriteLine("Rhino Application 类型获取成功");
rhino = Activator.CreateInstance(type);
Console.WriteLine("Rhino Application 实例创建成功");
// Wait until Rhino is initialized before calling into it
const int bail_milliseconds = 15 * 1000;
var time_waiting = 0;
Console.WriteLine("开始启动 Rhino");
while (0 == rhino.IsInitialized())
{
Thread.Sleep(100);
Console.WriteLine("等待 Rhino 启动");
time_waiting += 100;
if (time_waiting > bail_milliseconds)
{
Console.WriteLine("Rhino initialization failed");
return;
}
}
while (rhino.Visible == 0)
{
rhino.Visible = 1;
Thread.Sleep(100);
}
很奇怪,我代码都测试通过了,结果部署到另一台电脑上时失败了。测试通过的电脑的操作系统为 win10 企业版,测试失败的为 win10 家庭版,除此之外没有什么不同。失败的现象很让人迷惑,Visible = 1 赋值不工作,这个属性的值始终都是 0,界面还没有显示出来,但进程有 Rhino.exe,没有其他报错信息