What's the difference in these ways of creating the static instance for a singleton?
I have had a bug recently that only manifested itself when the library was built as a release build rather than a debug build. The library is a .NET dll with a COM wrapper and I am using CoCreateInstance to create a class from the dll in an unmanaged c++ app. When I finally tracked the bug down it was caused by accessing a singleton object. I had the singleton instance declared like so: private static readonly MyObjectType s_instance = new MyObjectType; and then accessed it with: public static MyObjectType Instance { get { return s_instance; } } this was failing. Changing it to: private static