I am getting an issue regarding running autocad application using C#. As i am beginner most of my code is copy pasted from net.
The problem is i am developing an web application using c# which will create an instantiate autocad instance at runtime. Every thing goes fine on development server as well as on my local IIS server. but when i am deploying the web application on the server(window server 8) i am getting the below error
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
at DQMF.CDQMF.createAacdApplicationInstance(String progID)
I think it is because of some privilege issue. as on my local machine autocad instance is running with privilege of system and on server(windows server 8) it is running(with development server) as administrative privilege.
AcadApplication createAacdApplicationInstance(string progID)
{
AcadApplication app = null;
try
{
app = (AcadApplication)Marshal.GetActiveObject(progID);
}
catch (Exception e)
{
try
{
Type acType = Type.GetTypeFromProgID(progID);
app = (AcadApplication)Activator.CreateInstance(acType, true);
app.Visible = false;
app.Width = 1;
app.Height = 1;
app.WindowState = AutoCAD.AcWindowState.acMin;
app.Visible = false;
}
catch (Exception ex)
{
//File.AppendAllText("D:/test/DQMS_log.txt", ex.Message+" progID is: "+progID+Environment.NewLine+"app caption: "+app.Caption);
}
}
return app;
}
If you want some more detail i can give