The the code that we use is below, and never fails us. If you have problems on one computer, but not on other computers, you may need to re-install Rhino on the problematic machine.
private dynamic _rhino;
public void StartRhino()
{
// Try creating an instance of Rhino
try
{
const string rhinoId = "Rhino.Application";
Type type = Type.GetTypeFromProgID(rhinoId);
_rhino = Activator.CreateInstance(type);
}
catch (Exception e)
{
Log("Error creating COM instance, {0}", e);
return;
}
if (null == _rhino)
{
Log("Failed to create Rhino application");
return;
}
// Wait until Rhino is initialized before calling into it
const int bailMilliseconds = 15 * 1000;
int timeWaiting = 0;
while (0 == _rhino.IsInitialized())
{
Thread.Sleep(100);
timeWaiting += 100;
if (timeWaiting > bailMilliseconds)
{
Console.WriteLine("Rhino initialization timed out: Failed");
return;
}
}
Logger.Info("RhinoCom Initialisation took {0} ms.", timeWaiting);
_rhino.Visible = 1;
}