打开绘图时出现“解密数据错误”异常

发布于 2024-09-28 01:19:20 字数 1130 浏览 6 评论 0原文

我有一个程序可以对一些图纸进行批处理。当我尝试打开其中一张图时,它抛出异常“解密数据时出错”。该绘图尤其是由 AutoCAD 以外的第三方工具生成的。此外,此问题仅出现在 AutoCAD 2011 中。在 AutoCAD 2010 中,它会提示用户该文件是在 AutoCAD 外部生成的,但他们可以单击,批处理将继续。我尝试使用托管 .NET API 和 COM Interop API 打开它,但都给出了相同的错误。

这是来自 AutoCAD 表单的帖子,但它没有为我提供解决方案:

http://forums.autodesk.com/t5/NET/Error-Decrypting-Data-Acad-2011/td-p/2661762/highlight/true

托管 API

string drawingFilePath = @"C:\Drawings\MyDrawing.dwg";
Application.DocumentManager.Open(drawingFilePath, false);

COM 互操作

string drawingFilePath = @"C:\Drawings\MyDrawing.dwg";
Object comAutoCAD = Application.AcadApplication;
Object comDocuments = comAutoCAD.GetType().InvokeMember("Documents", BindingFlags.GetProperty, null, comAutoCAD, new object[] { });

Object comDocument = comDocuments.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, comDocuments,
    new object[] { drawingFilePath, false, Type.Missing });
Document.FromAcadDocument(comDocument);

I have a program that does batch processing on some drawings. One of the drawings throws an exception "Error Decrypting Data" when I try to open it. This drawing in particular was generated by a third-party tool other than AutoCAD. In addition, this problem only occurs in AutoCAD 2011. In AutoCAD 2010 it prompts the user that the file was generated outside of AutoCAD but they can click and the batch will continue. I've tried opening it using both the managed .NET API and the COM Interop API but both give the same error.

Here is a post from the AutoCAD formus though it didn't provide me with a solution:

http://forums.autodesk.com/t5/NET/Error-Decrypting-Data-Acad-2011/td-p/2661762/highlight/true

Managed API

string drawingFilePath = @"C:\Drawings\MyDrawing.dwg";
Application.DocumentManager.Open(drawingFilePath, false);

COM Interop

string drawingFilePath = @"C:\Drawings\MyDrawing.dwg";
Object comAutoCAD = Application.AcadApplication;
Object comDocuments = comAutoCAD.GetType().InvokeMember("Documents", BindingFlags.GetProperty, null, comAutoCAD, new object[] { });

Object comDocument = comDocuments.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, comDocuments,
    new object[] { drawingFilePath, false, Type.Missing });
Document.FromAcadDocument(comDocument);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是在用心讲痛 2024-10-05 01:19:20

AutoCAD 论坛中的某人发布了一个对我有用的答案。

http://forums .autodesk.com/t5/NET/Error-Decrypting-Data-Acad-2011/td-p/2661762/page/2

这是一个示例:

const string systemVar_DwgCheck = "DWGCHECK";
Int16 dwgCheckPrevious = (Int16)Application.GetSystemVariable(systemVar_DwgCheck);
Application.SetSystemVariable(systemVar_DwgCheck, 2);

Document document = Application.DocumentManager.Open(@"C:\Drawings\MyDrawing.dwg", false);
// Do stuff...

Application.SetSystemVariable(systemVar_DwgCheck, dwgCheckPrevious);

Someone from the AutoCAD forums posted an answer that works for me.

http://forums.autodesk.com/t5/NET/Error-Decrypting-Data-Acad-2011/td-p/2661762/page/2

Here is an example:

const string systemVar_DwgCheck = "DWGCHECK";
Int16 dwgCheckPrevious = (Int16)Application.GetSystemVariable(systemVar_DwgCheck);
Application.SetSystemVariable(systemVar_DwgCheck, 2);

Document document = Application.DocumentManager.Open(@"C:\Drawings\MyDrawing.dwg", false);
// Do stuff...

Application.SetSystemVariable(systemVar_DwgCheck, dwgCheckPrevious);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文