J
joes.staal
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::CLIObject::Value(42); // Is a wrapper around
Native::SingleObject::instance().value(int i)
Native::SingleObject::instance().value(13);
Console::WriteLine("Value in CLI object is {0}",
CLIAssembly::CLIObject::Value());
Console::WriteLine("Value in Native object is {0}",
Native::SingleObject::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::CLIObject::Value(42); // Is a wrapper around
Native::SingleObject::instance().value(int i)
Native::SingleObject::instance().value(13);
Console::WriteLine("Value in CLI object is {0}",
CLIAssembly::CLIObject::Value());
Console::WriteLine("Value in Native object is {0}",
Native::SingleObject::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