c# - Singleton Implementation Works Fine on 32-bit but not 64-bit -
I am working on a single application with a shared object that has reached through a singleton. It's working fine on 32-bit, but on 64-bit it's not going to be locked properly. For the constructor of my object I have a code that checks for some configuration RIR key and prompts the user if the user does not exist. On 32 bit I'm only being shown several times at a 64-bit prompt as expected. My code is below:
Private static readable object padlock = new object (); Private Static MyClass _instance = null; Public Static MyClass Instance {Get (lock (padlock) {if (_instance == null) {_instance = new MyClass ()); }} Return _instance; }}
Any input is highly appreciated.
Edit to include sample usage:
public other object () {initialization (); MyClass.Instance.OtherObjectOrSomething = this; This.Load + = New system. Event Handler & lt; EventArgs & gt; (Other object_load); }
Re-edited This is going on inside an Office AddIn, thus the Beetle is determined by the installation of the office. I define a parametric constructor which is private.
Thank you
A little irregular constructor was removed
This can be something internal in the constructor's code, which causes many hints. The view of the registry is different from the 32-bit process, in which the 64-bit process occurs, so that they can respond to different external conditions
Comments
Post a Comment