Boost logo

Boost Users :

From: KonT (ksoft1_at_[hidden])
Date: 2006-02-21 19:46:19


Hi,

I have only recently started using boost.

platform win2k, winxp
dev vs.net 2003 (vc7.1)

I have downloaded the src & built boost libs using bjam. I have had no problems using them
in std C++ apps.

However, I have struck a prob in a case which has involved replacing my date/time code
with boost::gregorian classes.

I build an umanaged static lib which uses the boost date time stuff. The lib has been used
successfully in a test harness (std C++ console app).
This lib is then included in a manged C++ dll which exposes a std CLI interface, hiding
the native c++ stuff.
The managed dll is then included in a C# app.

before I converted to boost, the whole arrangement worked ok.
However now the C# app crashes when it calls code which jumps into the boost date lib.

I have attempted to read up on the issue involved in having such a structure, & following
advice from the ms on line help I have added a 'ManagedWrapper' class to the managed c++
dll (as per MS docs) which provides static methods to initialise the C++ run time lib.

public __gc class ManagedWrapper {
public:
    static int minitialize() {
       int retval = 0;
       try {
             __crt_dll_initialize();
       } catch(System::Exception* e) {
          Console::WriteLine(e);
          retval = 1;
       }
       return retval;
    }
    static int mterminate() {
       int retval = 0;
       try {
             __crt_dll_terminate();
       } catch(System::Exception* e) {
          Console::WriteLine(e);
          retval = 1;
       }
       return retval;
    }
};

The C# calls the appropriate methods in Main

                static void Main(string[] args)
                {
                        ManagedWrapper.minitialize();

                        TestFs();
                        TestAcct();
                        TestAccMgr();

                        ManagedWrapper.mterminate();
                }

At this point I think that I need to initialise statics within the boost lib.

Does anyone have any advice on how to solve this issue (even if it means totally
rearranging the dll wrapping a lib structure).

Thanks

Kon Tantos


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net