View Single Post
  #1 (permalink)  
Old August 30th, 2005, 08:45 AM
scando scando is offline
Registered User
 
Join Date: Aug 2005
Location: , Texas, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get running Instance of a Process not in ROT?

Anyone,

I am using C# code to start and interact with Microstation and have run into a small problem that I can't figure out.

The following code gets the running machine processes and if "ustation" is not already running starts Microstation.
This works great!

If "ustation" is already running, the following code tries to obtain a running instance of Microstation by looking the application up in the Running Object Table.
This fails because Microstation does not register itself in the ROT.

How do I return an object.type (comparable to the return type of GetActiveObject) that is attached to a running process not in the ROT?

Here is the code I am using...

try
{ Process[] ustationProcesses = Process.GetProcessesByName("ustation");

if ( ustationProcesses.Length == 0 )
    {
     app = new MicroStationDGN.Application();
    }
else
    {
     app = (MicroStationDGN.Application)System.Runtime.Intero pServices.Marshal.GetActiveObject("MicroStationDGN .Application");
    }
     return(app);
}
catch (System.Exception ex)
{
MessageBox.Show("Starting Microstation generated the following exception:\n"+ex.ToString());
}

BTW, the code works for AutoCAD; It registers itself in the ROT.

Thanks in advance for any input...
Daren....
Reply With Quote