Hi,
I know this has been asked earlier on, however, none of the other
threads where I looked solved the following problem.
1. I've got a native C++ library (lib, not a dll) with a singleton.
2. I've got a C++/CLI program with a wrapper around some functions in
the singleton of the native lib.
3. When I run my program, the wrappers instantiate their own copy of
the singleton, i.e.
CLIAssembly::CL IObject::Value( 42); // Is a wrapper around
Native::SingleO bject::instance ().value(int i)
Native::SingleO bject::instance ().value(13);
Console::WriteL ine("Value in CLI object is {0}",
CLIAssembly::CL IObject::Value( ));
Console::WriteL ine("Value in Native object is {0}",
Native::SingleO bject::instance ().value());
gives as output
Value in CLI object is 42
Value in Native object is 13
Only when I put the source code of the native lib in the CLI/C++
program project I get the behaviour I'd expect.
I've tried various options:
- Compiling the native lib with /clr
- adding #pragma managed and #pragma unmanaged around the include for
the native code in the CLI project.
All to no avail.
Any help and ideas would be much appreciated.
Joes
I know this has been asked earlier on, however, none of the other
threads where I looked solved the following problem.
1. I've got a native C++ library (lib, not a dll) with a singleton.
2. I've got a C++/CLI program with a wrapper around some functions in
the singleton of the native lib.
3. When I run my program, the wrappers instantiate their own copy of
the singleton, i.e.
CLIAssembly::CL IObject::Value( 42); // Is a wrapper around
Native::SingleO bject::instance ().value(int i)
Native::SingleO bject::instance ().value(13);
Console::WriteL ine("Value in CLI object is {0}",
CLIAssembly::CL IObject::Value( ));
Console::WriteL ine("Value in Native object is {0}",
Native::SingleO bject::instance ().value());
gives as output
Value in CLI object is 42
Value in Native object is 13
Only when I put the source code of the native lib in the CLI/C++
program project I get the behaviour I'd expect.
I've tried various options:
- Compiling the native lib with /clr
- adding #pragma managed and #pragma unmanaged around the include for
the native code in the CLI project.
All to no avail.
Any help and ideas would be much appreciated.
Joes
Comment