This post was updated on .
Hello,
I recently setup QuantLib-SWIG 1.6 for C# using the Visual Studio 2012 compiler (vc120), and I'm very happy that I can finally use QuantLib 1.6 in our Visual Studio 2013 C# solutions. I'm able to run the BermudanSwaption and EquityOption examples under the Win32 platform in Debug and Release mode, but for the x64 platform I'm only able to run in Release mode. The thing is, I need it to be able to run in Debug mode when using the x64 platform. Unfortunately, when running x64/Debug with debugging (F5) I get the following TypeInitializationException The type initializer for 'QuantLib.NQuantLibcPINVOKE' threw an exception. and under the same settings without debugging (Ctrl+F5) I get Unhandled Exception: System.TypeInitializationException: The type initializer for 'QuantLib.NQuantLibcPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. - --> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRES ULT: 0x8007000B) at QuantLib.NQuantLibcPINVOKE.SWIGExceptionHelper.SWIGRegisterExceptionCallbacks_NQuantLibc(ExceptionDelegate applica tionDelegate, ExceptionDelegate arithmeticDelegate, ExceptionDelegate divideByZeroDelegate, ExceptionDelegate indexOutOf RangeDelegate, ExceptionDelegate invalidCastDelegate, ExceptionDelegate invalidOperationDelegate, ExceptionDelegate ioDe legate, ExceptionDelegate nullReferenceDelegate, ExceptionDelegate outOfMemoryDelegate, ExceptionDelegate overflowDelega te, ExceptionDelegate systemExceptionDelegate) at QuantLib.NQuantLibcPINVOKE.SWIGExceptionHelper..cctor() in c:\Program Files\QuantLib\QuantLib-SWIG-1.6\CSharp\csha rp\NQuantLibcPINVOKE.cs:line 105 --- End of inner exception stack trace --- at QuantLib.NQuantLibcPINVOKE.SWIGExceptionHelper..ctor() at QuantLib.NQuantLibcPINVOKE..cctor() in c:\Program Files\QuantLib\QuantLib-SWIG-1.6\CSharp\csharp\NQuantLibcPINVOKE .cs:line 125 --- End of inner exception stack trace --- at QuantLib.NQuantLibcPINVOKE.new_Date__SWIG_1(Int32 jarg1, Int32 jarg2, Int32 jarg3) at QuantLib.Date..ctor(Int32 d, Month m, Int32 y) in c:\Program Files\QuantLib\QuantLib-SWIG-1.6\CSharp\csharp\Date.c s:line 102 at BermudanSwaption.Run.Main(String[] args) in c:\Program Files\QuantLib\QuantLib-SWIG-1.6\CSharp\examples\BermudanSw aption.cs:line 72 I have read other solutions to this problem, like checking to see if the proper Library Dependencies are set and setting the platform properly, but these solutions didn't help as I have already implemented them. I even rebuilt Boost and QuantLib 1.6 under the x64/Debug configurations, but this still didn't help. Is there anyone that could help me out with this issue? This is rather critical for me and I can't seem to figure it out. I should be able to give you any other information you request. Thanks in advance. |
Hi Luigi, I've recently figured out how to build and run QuantLib-SWIG x64 under Release and Debug mode for C# using the Visual Studio C++ 2013 (vc120) compiler. I realized that not only do the include and library directory paths must be correct for both Boost and QuantLib, but those two applications must also have their output DLLs placed in appropriate directories. After I better reorganized these locations to separate x64/x86 for Release and Debub mode, I was successful in running all versions in VS 2013. Honestly, I'm not 100% sure this was the final push to provide me with a valid build, but after repeating the process laid out below I have been able to run it fine. Below are the work instructions I followed.
To test whether or not this process produced for you valid 64-bit DLLs, run the BermudanSwaption and EquityOption projects provided in the QuantLib-SWIG solution. Before doing this, be sure that the NQuantLibc and NQuantLib DLLs are correctly referenced in Properties->Build Events->Pre-Build Event Command Line. Mine look like copy "$(SolutionDir)cpp\bin\$(qlCompilerTag)\$(Platform)\$(ConfigurationName)\NQuantLibc.dll" "$(TargetDir)" copy "$(SolutionDir)csharp\bin\$(Platform)\$(ConfigurationName)\NQuantLib.dll" "$(TargetDir)" On Fri, Jul 17, 2015 at 11:27 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Ok, thanks. Most of the steps seem to be those that we already describe in the installation guide. I'll try the others next week when I get back to work. Luigi On 16:51, Tue, Jul 21, 2015 Grant Bartel <[hidden email]> wrote:
-- <http://leanpub.com/implementingquantlib/> ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
For those interested in using QuantLib 1.6 in C# projects running in 64-bit mode, there is a newly available NuGet package I pushed named NQuantLib64. This package was built following the steps detailed in my previous post, and no modifications were made to the original QuantLib library prior to building.
Enjoy! |
Free forum by Nabble | Edit this page |