I can make a Loki singleton with Common Language Runtime (CLR) support as long as I use single threading. This is fine:
typedef SingletonHolder<CryptoForm, CreateUsingNew, DefaultLifetime> Crypto;
...but the moment I add in ClassLevelLockable, I get this error:
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (Loki.Mutex): (0x02000053). Singleton.obj LMAdaptRsa
I have "Singleton.cpp" added directly to my VS "LMAdaptRsa" project (it is not pre-built).
I forgot to mention: I'm building with VS 2k8, SP1.
p.s. how do I search these forums? I don't see an option...
Ok, with the help of this article:
...I found the problem. My header that was declaring my contained type (and a SingletonHolder typedef) had this:
...but the Singleton.cpp file I included in my make did not have that #define statement. It caused its translation unit to have a Mutex of a different size. Without the /clr switch, that problem goes undetected.
So I made a local copy of Singleton.cpp in my VS project, and changed its #include statement to point to my own header that was giving the #define. Problem solved.