Autocad Instance not creating after deployment

半腔热情 提交于 2019-12-11 19:48:32

问题


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


回答1:


Your marshalling is failing because the ASP.NET process runs on a separate account, and has a completely different Running Object Table (ROT). I am pretty sure for this to work you'll have to instanciate a new session from the ASP.NET side.




回答2:


When working with visual interops, it is not as straightforward to run instances of applications that expect direct user interaction from asp.net.

You may have to use a windows form or WPF application to work with AutoCAD. The issue may be that the AutoCAD.Application interop does not allow for non-visual interaction.



来源:https://stackoverflow.com/questions/22500464/autocad-instance-not-creating-after-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!