系统算术异常:Delphi 通过 C++/CLI 包装器调用 C# DLL
我有一个 C# DLL,它使用 XslCompiledTransform 类进行 xml 操作。我窃取了 C# DLL 的 C++/CLI 包装器。
当使用 Delphi 5 实现 C++/CLI 包装器时,我收到系统算术错误。下面是 Delphi 5 声明:
procedure XsltMethod(XmlPath, XsltPath: PWideChar); cdecl; external 'ahma.dll';
C# 公共方法的主体创建了一个新的 XslCompiledTransform 对象,并且当新创建的对象运行其 load 方法时,会立即弹出异常。例如:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(XsltFile);
如前所述,.NET DLL 抛出的异常是系统算术异常。仅当从 Delphi 可执行文件调用时才会发生这种情况。
我想我应该提到再次调用对象的 load 方法效果很好。因此,捕获异常并运行该方法进行第二次“传递”就像弹出窗口阻止程序一样。当然,也有例外。
I have a C# DLL that uses the XslCompiledTransform class for xml manipulations. I stole a C++/CLI wrapper for the C# DLL.
When using Delphi 5 to implement the C++/CLI wrapper, I receive a System Arithmetic error. Here is the Delphi 5 declaration:
procedure XsltMethod(XmlPath, XsltPath: PWideChar); cdecl; external 'ahma.dll';
The body of the C# public method creates a new XslCompiledTransform object and the exception pops up right when the newly created object runs its load method. For example:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(XsltFile);
As mentioned earlier, the exception thrown from the .NET DLL is a System Arithmetic Exception. This only happens when called from a Delphi executable.
I guess I should mention calling the object's load method again works fine. So catching the exception and running the method for a second "pass" acts like a popup blocker. But for exceptions, of course.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您会遇到浮点控制寄存器的差异,如此处所述。另请参阅此质量控制报告。您可以尝试拨打 Set8087CW($133F);在您的 Delphi 程序中。此后请小心 Delphi 代码中的浮点问题。
Maybe you suffer from differences in the Floating-Point Control Register as stated here. Also see this QC report. You could try calling Set8087CW($133F); in your Delphi program. Be cautious of floating point problems in your Delphi code after that.
随机想法:
Random thoughts: