本文介绍了部署后未创建 Autocad 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到有关使用 C# 运行 autocad 应用程序的问题.因为我是初学者,所以我的大部分代码都是从网上复制粘贴的.

I am getting an issue regarding running autocad application using C#. As i am beginner most of my code is copy pasted from net.

问题是我正在使用 c# 开发一个 web 应用程序,它将在运行时创建一个实例化的 autocad 实例.在开发服务器和我的本地 IIS 服务器上一切正常.但是当我在服务器(窗口服务器 8)上部署 Web 应用程序时,我收到以下错误

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)

我认为这是因为某些特权问题.因为在我的本地机器上,autocad 实例以系统权限运行,而在服务器(Windows 服务器 8)上,它以管理权限运行(使用开发服务器).

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

推荐答案

在使用可视化互操作时,运行需要来自 asp.net 的直接用户交互的应用程序实例并不那么简单.

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

您可能必须使用 Windows 窗体或 WPF 应用程序才能使用 AutoCAD.问题可能是 AutoCAD.Application 互操作不允许非视觉交互.

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.

这篇关于部署后未创建 Autocad 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 04:43