Settings::instance().evaluationDate() produces exception in managed code

Posted by Boris Skorodumov on
URL: http://quantlib.414.s1.nabble.com/Settings-instance-evaluationDate-produces-exception-in-managed-code-tp7848.html

Hello,

I came across strange problem with Settings::instance().evaluationDate() when I am exposing it to .NET environment. (QuantLib - > Managed C++ - > C#).

In this case, I am catching exception such as "The exception unknown software exception (0x0020001) occurred in the application". This exception only happends when I call Settings::instance().evaluationDate(). I tested other classes/functions such as Date and some mathematical functions. As long as they not calling Settings::instance().evaluationDate() everything is working. I am bit puzzled because I do not understand this exeption.

Thank you,
Boris.

Below is a simple c++ code:

.....
class TestSettings
{
public:
    void test();
};
....

void TestSettings::test()
{
 
    Date todaysDate = Date::todaysDate();
    Settings::instance().evaluationDate() = todaysDate;
}



Below is a simple Managed c++ code:


#pragma once

#include <export/testsettings.hpp>

using namespace System;
//_________________________________________
namespace Wrapper
{
//____________________________________________
public ref class TestSettingsManaged
{
private:
    TestSettings *ptr;

public:
    TestSettingsManaged(void);

    !TestSettingsManaged();
    ~TestSettingsManaged();

    void testManaged();
};



#include "StdAfx.h"
#include "TestSettingsManaged.hpp"

namespace Wrapper
{
//__________________________________________________
TestSettingsManaged::TestSettingsManaged(void)
{
    ptr = new TestSettings();
}
//__________________________________________________
TestSettingsManaged::!TestSettingsManaged()
{
    delete ptr;
}
//__________________________________________________
TestSettingsManaged::~TestSettingsManaged()
{
    this->!TestSettingsManaged();
}
//__________________________________________________
void TestSettingsManaged::testManaged()
{   
    ptr->test();
}
//__________________________________________________
}

And finally console C# console application

using System;
using Wrapper;

namespace WrapperTest
{
    class Program
    {
       static void Main(string[] args)
        {
          TestSettingsManaged setting = new TestSettingsManaged();
          setting.testManaged();
       }
   }
}


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users