我找到了一段代码,可以使用 objectARX 命令在 autocad 中打开一个 dwg 文件。当我在类库项目中编写这段代码时,它可以成功运行,但是当我想将这段代码放在我的 Windows 应用程序中时,问题就发生了.它给了我这个错误信息:
The type initializer for '< Module >' threw an exception.
Inner Exception : The C++ module failed to load during process initialization.
我的代码是:
String MyDWGFilePath = @"\\Server\SharedFolder\Projects\File1.dwg";
DocumentCollection dm = Application.DocumentManager;
Document doc = null;
if(File.Exists(MyDWGFilePath))
{
doc = dm.Open(MyDWGFilePath, false);
Application.DocumentManager.MdiActiveDocument = doc;
}
注意:我从 autocad 安装文件夹添加了 acdbmgd.dll 和 acmgd.dll,还从 COM 引用添加了 AutoCAD 和 AXDBLib。
请帮帮我...
最佳答案
我的理解是 Autodesk 将他们的一些(但不是全部*)AutoCAD 库设置为无法在 AutoCAD 地址空间之外运行。您可能遇到了此许可限制。 (我正在抓取 Autodesk 的网站以获取支持这一点的引用)。
编辑:RealDWG如果您要在 AutoCAD 之外进行 .dwg 操作,Autodesk 希望您购买该产品。 (仍在寻找 AcDbMgd 仅在 acad 链接内部运行...)
(*) 我知道 AcGe 类/dll 组可以在 AutoCAD 之外使用 - 我曾经在某些单元测试中使用它们。我认为任何操作 .dwg 数据库的东西都必须在 AutoCAD 内部运行。
关于c# - 错误 : typeInitializationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8709818/