sergvil | 7 Feb 06:03
Picon
Favicon

.NET Framework 4.0 Application Runtime Exceptions Problem


Hello,

I have been working with QuantLib since Oct'11 and I think it works great. I
used it with .NET Framework 3.5 and it worked perfectly. I use QuantLib and
SWIG for C#.

Now I am developing a .NET Framework 4 WPF application with some Quantlib
Bond Calculations and I am having some problems:

When I make some testing, each time the app tries to create any QuantLib
object or tries to execute any method it throws this exception (click on
name for description):

http://msdn.microsoft.com/es-es/library/0htdy0k3%28v=vs.100%29.aspx
pInvokeStackImbalance 

When I try the application on Visual Studio and I have
PInvolkeStackImbalance activated on MDA exceptions, I use to receive several
PInvoke warnings (green coloured) on each execution, but application works
perfectly. But when I try to execute on Windows, those warnings are
exceptions that cause application to crash.

I tried to fix it making some modifications on QuantLib_vc10 project. I
found at other forum this solution for the exception we are talking about:

On each dll method call defined on NQuantLibcPINVOKE that throws the
exception, like this:

  [DllImport("NQuantLibc", EntryPoint="CSharp_new_TARGET")]
  public static extern IntPtr new_TARGET();

We can avoid the exception using one parameter:

  [DllImport("NQuantLibc", EntryPoint="CSharp_new_TARGET", CallingConvention
= CallingConvention.Cdecl)]
  public static extern IntPtr new_TARGET();

Using this, I can execute the app on Visual Studio with no warnings. But
when app is installed on windows I receive other exception:

"The type initializer for 'QuantLib.NQuantLibcPINVOKE' threw an exception."

And the application crashes.

After trying this solution, now I have no idea how to fix it.

Is there any solution? Anybody knows how to compile QuantLib via SWIG in
order to execute QuantLib Calculations on .NET Framework 4.0 applications?

If somebody has SWIG-QuantLib dlls (NQuantLib.dll and NQuantLibc.dll)
compatible with .NET Framework 4.0 I would be so gratefull if I could
receive them.

Thank you in advance.

Best Regards.

Sergio
--

-- 
View this message in context: http://old.nabble.com/.NET-Framework-4.0-Application-Runtime-Exceptions-Problem-tp33276539p33276539.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d

Gmane