[英]System Arithmetic Exception: Delphi calling C# DLL via C++/CLI wrapper
I have a C# DLL that uses the XslCompiledTransform class for xml manipulations. 我有一个使用XslCompiledTransform类进行xml操作的C#DLL。 I stole a C++/CLI wrapper for the C# DLL. 我偷了C#DLL的C ++ / CLI包装器。
When using Delphi 5 to implement the C++/CLI wrapper, I receive a System Arithmetic error. 使用Delphi 5实现C ++ / CLI包装器时,出现系统算术错误。 Here is the Delphi 5 declaration: 这是Delphi 5声明:
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. C#公共方法的主体创建一个新的XslCompiledTransform对象,并且当新创建的对象运行其load方法时,该异常立即弹出。 For example: 例如:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(XsltFile);
As mentioned earlier, the exception thrown from the .NET DLL is a System Arithmetic Exception. 如前所述,.NET DLL引发的异常是系统算术异常。 This only happens when called from a Delphi executable. 这仅在从Delphi可执行文件中调用时发生。
I guess I should mention calling the object's load method again works fine. 我想我应该提一下再次调用对象的load方法可以正常工作。 So catching the exception and running the method for a second "pass" acts like a popup blocker. 因此,捕获异常并为第二次“通过”运行该方法就像一个弹出窗口阻止程序。 But for exceptions, of course. 但是当然有例外。
Random thoughts: 随意的想法:
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); 您可以尝试致电Set8087CW($ 133F); in your Delphi program. 在您的Delphi程序中。 Be cautious of floating point problems in your Delphi code after that. 此后,请谨慎使用Delphi代码中的浮点问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.