I tried to implement a singleton class as follows (I am using VS2008 SP1):
namespace firstNamespace
{
class SingletonClass
{
private SingletonClass() {}
public static readonly SingletonClass Instance = new SingletonClass();
}
}
When I want to access it from a class in another namespace (it seems that this is a problem, it works in the same namespace), for example:
namespace secondNamespace
{
...
firstNamespace.SingletonClass inst = firstNamespace.SingletonClass.Instance;
...
}
I get a compiler error:
error CS0122: 'firstNamespace.SingletonClass' is inaccessible due to its protection level
Does anyone have any ideas how to solve this?
Thank you very much in advance!
source
share