System arithmetic exception: Delphi calls C # DLL via C ++ / CLI wrapper
I have a C # DLL that uses the XslCompiledTransform class to manipulate the xml. I stole a C ++ / CLI wrapper for a C # DLL.
When using Delphi 5 to implement a C ++ / CLI wrapper, I get a system arithmetic error. Here's a Delphi 5 declaration:
procedure XsltMethod(XmlPath, XsltPath: PWideChar); cdecl; external 'ahma.dll';
The body of a C # public method creates a new XslCompiledTransform object, and the exception is thrown immediately when the newly created object uses its load method . For example:
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(XsltFile);
As mentioned earlier, an exception thrown from a .NET DLL is a system arithmetic exception. This only happens when called from a Delphi executable.
I think I should mention that calling the load method works fine again. Thus, catching the exception and running the method for the second "pass" acts like a popup blocker. But for the exceptions, of course.
Random thoughts:
- I think you should start by debugging your build from Visual Studio. Insert a message or other wait expression in your Delphi code, then join the process from Visual Studio. The C # trace can give a couple of clues as to what is going wrong. If you can't get it to work, at least add logging of incoming parameters.
- In delphi, you don't need to hide the backslash.
- Are you sure the E0434F4D isn't an innocent first-chance exception? If you are not debugging (or continuing from the JIT debugger exception stopping, which I'm not entirely sure about Delphi 5) is the behavior really wrong?
- Can we refer to a "native Win32 assembly" as a "DLL" as we have called them for the past 20 years? :-)
source to share