D
David
Hello,
I'm writing a C# class library that may be called by non-.Net
applications. The main class of this class libray is a ServicedComponent
so that non-.Net application can call this class as a standard COM+
component. Now, I want that class to be a singleton. Once loaded, the
values moslty never change.
I tried using this pattern:
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
private Singleton(){}
public static Singleton Instance
{
get
{
return instance;
}
}
}
However, it throws an exception complaining about ServicedComponent
thats needs a public constructor.
The error raised is:
An unhandled exception of type
'System.EnterpriseServices.RegistrationException' occurred in
system.enterpriseservices.dll
Additional information: Invalid ServicedComponent-derived classes were
found in the assembly.
(Classes must be public, concrete, have a public default constructor,
and meet all other ComVisibility requirements)
I'm writing a C# class library that may be called by non-.Net
applications. The main class of this class libray is a ServicedComponent
so that non-.Net application can call this class as a standard COM+
component. Now, I want that class to be a singleton. Once loaded, the
values moslty never change.
I tried using this pattern:
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
private Singleton(){}
public static Singleton Instance
{
get
{
return instance;
}
}
}
However, it throws an exception complaining about ServicedComponent
thats needs a public constructor.
The error raised is:
An unhandled exception of type
'System.EnterpriseServices.RegistrationException' occurred in
system.enterpriseservices.dll
Additional information: Invalid ServicedComponent-derived classes were
found in the assembly.
(Classes must be public, concrete, have a public default constructor,
and meet all other ComVisibility requirements)