Any soultions to this old thread of calling quantlib from managed code?

Posted by Cliffy on
URL: http://quantlib.414.s1.nabble.com/Any-soultions-to-this-old-thread-of-calling-quantlib-from-managed-code-tp8168.html

Hi,

I have a similar issue to this old thread -

http://old.nabble.com/Settings%3A%3Ainstance%28%29.evaluationDate%28%29-produces-exception-in-managed-code-to25479768.html#a25479768

I wrap quantlib.lib to a managed C++ dll and referenced it from an ASP.NET aspx web page in C#. It looks fine until it calls Settings::instance().evaluationDate().

I have a different exception but I think the cause is the same -

"The function must be called from the default domain"

It fails in
allocation a static variable in singleton.hpp

static std::map<Integer, boost::shared_ptr<T> > instances_;


 template <class T>
    #if defined(QL_PATCH_MSVC) && defined(_MANAGED)
    inline  // this seems to be required when CLR support is enabled
    #endif
    inline T& Singleton<T>::instance() {
        static std::map<Integer, boost::shared_ptr<T> > instances_;

I did some search on the web, found some same issues but did not find any solutions.
e.g.

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/cd3c34a6-84f9-4e2b-a483-12e179eb84b7

And there quite a few posts on the web about problems using static variable in unmanaged codes in a managed application.

Anyone has success in implementing for quantlib as described? Or any suggestions are very apprecilated.

Also, is SWIG the answer? I've never used it. Have tried to load QuantLib_vc9.sln from ..\QuantLib-SWIG-1.0\CSharp to 2008 C# built fine but get some errors when running the examples. Any documents explain how to run quantlib SWIG?


Thanks