I am connecting to an instance of Microstation and processing the design file as below, but I don't understand how I can connect to a specific instance of Microstation if multiple instances of ustation.exe are running. The code below connects to an instance, but I would like to be able to specify the instance if multiple are running. In the code below I am throwing an exception if I connect to microstation but then discover that multiple ustation.exe are runnning (backwards logic I know). I want to know that 'yes 3 ustation.exe and I have determined that instance 2 is running the dgn that I want so I will connect to it and run'.
bool connected = false;
_app = new BCOM.ApplicationClass();
if(_app == null)
throw new Exception("Failed to connect to instance of ustation.exe");
if (_app.ActiveDesignFile.IsActive)
{
Process[] processes = Process.GetProcessesByName("ustation");
if (processes.Length > 1)
{
// If I have multiple instances I want to specify who to connect to
throw new Exception("multiple ustation.exe running. Who did I connect to?");
}
connected = true;
}
else
{
throw new Exception("Connected to ustation.exe but no active design file");
}
return connected;