Hi, I have this code
try
{
Type type = Type.GetTypeFromProgID("Rhino5x64.Application", true);
if (type == null)
{
logger.Error("type = null / Cannot find the COM type of Rhino5x64.Application", MethodBase.GetCurrentMethod().DeclaringType.FullName);
return;
}
else
try
{
// Crea una instancia di Rhino per lanciare i comandi
rhino = Activator.CreateInstance(type);
}
catch (Exception e)
{
logger.Error($"Exception on CreateInstance Rhino: {e.Message}", MethodBase.GetCurrentMethod().DeclaringType.FullName);
}
}
catch (Exception e)
{
logger.Error($"GetTypeFromProgID Error Source: {e.Source}", MethodBase.GetCurrentMethod().DeclaringType.FullName);
logger.Error($"Cannot find the COM type of Rhino5x64.Application - Message: {e.Message}", MethodBase.GetCurrentMethod().DeclaringType.FullName);
}
if (null == rhino)
{
logger.Error("Failed to create Rhino application", MethodBase.GetCurrentMethod().DeclaringType.FullName);
return;
}
try
{
const int wait_milliseconds = 15 * 1000;
int time_waiting = 0;
while (0 == rhino.IsInitialized())
{
System.Threading.Thread.Sleep(100);
time_waiting += 100;
if (time_waiting > wait_milliseconds)
{
logger.Error("Rhino initialization failed", MethodBase.GetCurrentMethod().DeclaringType.FullName);
return;
}
}
System.Threading.Thread.Sleep(1200);
// rhino.Visible = 1;
}
catch (Exception e)
{
logger.Error($"Rhino Initialize Error Source: {e.Message}", MethodBase.GetCurrentMethod().DeclaringType.FullName);
return;
}
if (null == m_RhinoScript)
{
try
{
object obj = rhino.GetScriptObject();
m_RhinoScript = (IRhinoScript)obj;
}
catch (Exception ex)
{
logger.Error(string.Format("Error Creating Rhinoscript Object = {0}", ex.Message), MethodBase.GetCurrentMethod().DeclaringType.FullName);
return;
}
}
logger.Debug($"Opening File {file3dm}...", MethodBase.GetCurrentMethod().DeclaringType.FullName);
var openFileResult = rhino.RunScript("_Open " + file3dm, 0);
In the line
rhino = Activator.CreateInstance(type); throw the exceptionThe RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
This process can be called simultaneously on several occasions.
HELP