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® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Wed, 2009-09-16 at 16:15 -0400, Boris Skorodumov wrote:
> 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". No idea why that should happen. Did you try debugging the program? Also, you can try following the advice in <http://sourceforge.net/mailarchive/forum.php?thread_name=9b004f5c0803031142r5822aeb9ne49e9790230ad741%40mail.gmail.com&forum_name=quantlib-users>. Let me know if that helps. Later, Luigi -- Age is an issue of mind over matter. If you don't mind, it doesn't matter. -- Mark Twain ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thank you Nathan and Luigi for comments and link.
This is what I see. As long as in unmanaged code i have implementation of function test (which call Settings::instance().evaluationDate()) inside of the class TestSettings or as inline function in the same hpp file - no problems. it works with current singleton.hpp implementation. If I have implementation of test in separated cpp file then exeption occures. It occurs in either way with commented line 70 and substituted by #if defined(QL_PATCH_MSVC) or as it is right now in singleton.hpp. Also, when debuging from managed code, i cannot step into unmanaged code. VC2008 says for ptr below that "childrens cannot be evaluated" and just skip line ptr->test(); . I can step into unmanaged library in the first case when exeption is not produced.
void TestSettingsManaged::testManaged() {ptr->test();
}
Thank you,
Boris.
On Mon, Sep 21, 2009 at 11:14 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2009-09-22 at 14:25 -0400, Boris Skorodumov wrote:
> This is what I see. As long as in unmanaged code i have implementation > of function test (which call Settings::instance().evaluationDate()) > inside of the class TestSettings or as inline function in the same hpp > file - no problems. it works with current singleton.hpp > implementation. If I have implementation of test in separated cpp file > then exeption occures. It occurs in either way with commented line 70 > and substituted by #if defined(QL_PATCH_MSVC) or as it is right now > in singleton.hpp. Wait, I didn't quite get the last part. With the code as it is now, it doesn't work in either way. For it to work, you have to comment out the "inline" on line 70. Is this correct? Also: what happens if you define an inline function in a hpp file that calls Settings::instance().evaluationDate(), and then you implement the "test" function in a separate cpp and make it call the new function? Something like: ----- inline void setDate(const Date& d) { // in hpp file Settings::instance().evaluationDate() = d; } ----- void TestSettings::test() // in separate cpp file { Date todaysDate = Date::todaysDate(); setDate(todaysDate); } -- Olmstead's Law: After all is said and done, a hell of a lot more is said than done. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
>Wait, I didn't quite get the last part. With the code as it is now, it >doesn't work in either way. For it to work, you have to comment out the ">inline" on line 70. Is this correct? No, I do not need to touch singleton.hpp at all in order to make it works. Below is an example : If I define hpp like this : a) // in hpp file namespace QuantLib { class TestSettings { public: void test(); { Date d = Settings::instance().evaluationDate(); } }; } or like this b) // in hpp file namespace QuantLib { class TestSettings { public: void test(); }; void TestSettings::test() { Date d = Settings::instance().evaluationDate(); } } everything will work. I do not need to touch singleton.hpp file at all. But it I have something like this : // in hpp file namespace QuantLib { class TestSettings { public: void test(); }; // in cpp file namespace QuantLib { void TestSettings::test() { Date d = Settings::instance().evaluationDate(); } it will produce exception. The suggestion of Nathan to comment line #if defined(QL_PATCH_MSVC) && defined(_MANAGED) and add #if defined(QL_PATCH_MSVC) does not help. I still getting the same exception. Now suppose I do like this: // in hpp file namespace QuantLib { class TestSettings { public: void test(); }; // in cpp file namespace QuantLib { void TestSettings::test() { Date d = Date::todaysDate(); } than no exception. So, I assume it comes from Settings::instance().evaluationDate(); In the same time, debugger does not allow me to step into unmanaged function void TestSettings::test() (it just skipping line) which is possible in the case when implementation defined in hpp file. It is the same for Date d = Date::todaysDate(); or for Date d = Settings::instance().evaluationDate(); >Also: what happens if you define an inline function in a hpp file that >calls Settings::instance(). >evaluationDate(), and then you implement the >"test" function in a separate cpp and make it call the new function? // in hpp file namespace QuantLib { class TestSettings { public: void test(); }; inline void setDate(const Date& d) { // in hpp file Settings::instance().evaluationDate() = d; } } // in cpp file namespace QuantLib { void TestSettings::test() { Date d = Date::todaysDate(); setDate(d); } will produce still the same exception. Thank you, Boris. On Thu, Sep 24, 2009 at 10:00 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Thu, 2009-09-24 at 12:12 -0400, boris.skorodumov wrote:
> Below is an example : > [...] Hmm. Weird. What happens if you rewrite the instance() method in singleton.hpp like this? template <class T> #if defined(QL_PATCH_MSVC) && defined(_MANAGED) inline // this seems to be required when CLR support is enabled #endif T& Singleton<T>::instance() { static boost::shared_ptr<T> instance; if (!instance) instance = boost::shared_ptr<T>(new T); return *instance; } -- Grabel's Law: 2 is not equal to 3 -- not even for large values of 2. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
I just tried your suggestion. It is still the same exception. really weird.
boris. On Fri, Sep 25, 2009 at 11:08 AM, Luigi Ballabio <[hidden email]> wrote: On Thu, 2009-09-24 at 12:12 -0400, boris.skorodumov wrote: ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Fri, 2009-09-25 at 16:39 -0400, Boris Skorodumov wrote:
> I just tried your suggestion. It is still the same exception. really > weird. Yes. May you try and trim it down to a minimal example that we can send to some VC++ forum without including the whole library? Luigi -- There is no such thing as public opinion. There is only published opinion. -- Winston Churchill ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hello Luigi,
3 projects to test an exception I mentioned before: 1. QLib : static lib with minimum files from quantlib to be able to use settings. http://depositfiles.com/files/m9t6p9ipw 2. WrapperQlib : will generate managed C++ library to wrap testsettings class from QLib http://depositfiles.com/files/b0edhbp8j 3. WrapperTestQlib : C# console application to test testsettingsmanaged class. http://depositfiles.com/files/8zq2d83ef Boris. On Mon, Sep 28, 2009 at 9:00 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2009-09-28 at 15:30 -0400, Boris Skorodumov wrote:
> 3 projects to test an exception I mentioned before: Ok, except I wouldn't know where to go for help (I'm not familiar with the .Net world.) Do you know what the relevant forums are? May you post there? Thanks, Luigi -- Lubarsky's Law of Cybernetic Entomology: There is _always_ one more bug. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
One of the forum is http://www.codeguru.com
I just submitted question to them: http://www.codeguru.com/forum/showthread.php?t=485468
Thank you,
Boris.
On Tue, Sep 29, 2009 at 6:33 AM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2009-09-29 at 10:28 -0400, Boris Skorodumov wrote:
> One of the forum is http://www.codeguru.com > I just submitted question to them: > http://www.codeguru.com/forum/showthread.php?t=485468 Ok, thanks. Luigi -- Newton's Law of Gravitation: What goes up must come down. But don't expect it to come down where you can find it. Murphy's Law applies to Newton's. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |