Error calling QuantLib from Visual Studio C#

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Error calling QuantLib from Visual Studio C#

QEngineer
Hi,

I have a strange issue in my development environment: .NET 4.0 C# project calling QuantLib via C# SWIG Bindings.

While running C# project from Visual studio (either in Debug or Release modes), calls to QuantLib wrapper classes succeed only the first time. Any subsequent call throws the error below.
But the strange thing is that if the project is run outside of Visual Studio, it runs fine.
For info, the C# wrapper code was changed to use __cdecl, and CallingConvention cdecl parameter added to all DLL Imports.

Does anyone know the potential root cause, and how to solve it?


Code example:
Currency usd = new USDCurrency();
string s = usd.code(); // OK (first call is ok)
string s2 = usd.code(); // <-- Throws ERROR below

Error:

"The runtime has encountered a fatal error. The address of the error was at 0x6c36a81f, on thread 0x5ac. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack."

Thanks,
S.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users