471,350 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Singleton class in C#

Tim
How can I expose a Singleton C# class to COM?

I have implemented the singleton pattern for the C# class. The 'constructor'
of the class is protected. Now, I want to expose this class to a VB6 exe. But
COM expects the default constructor of the class to be available for
instantiating it through Interop. How can I create and access the
functionality of the C# Singleton class from VB6 Exe?
Feb 10 '06 #1
2 6362
well, 1 easiest way probably is that *do not* expose the singleton, expose
another COM/c# classes wrap around it.

hope it helps
"Tim" wrote:
How can I expose a Singleton C# class to COM?

I have implemented the singleton pattern for the C# class. The 'constructor'
of the class is protected. Now, I want to expose this class to a VB6 exe. But
COM expects the default constructor of the class to be available for
instantiating it through Interop. How can I create and access the
functionality of the C# Singleton class from VB6 Exe?

Feb 10 '06 #2
Hi,

"Tim" <Ti*@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
How can I expose a Singleton C# class to COM?
Note that the singleton you implemented is bounded to the appdomain that
created it, if you create another process (or appdomain in the same
process) you will have another instance.

I have implemented the singleton pattern for the C# class. The
'constructor'
of the class is protected. Now, I want to expose this class to a VB6 exe.
But
COM expects the default constructor of the class to be available for
instantiating it through Interop. How can I create and access the
functionality of the C# Singleton class from VB6 Exe?


You can wrap it in another class, this second class do nothing, just expose
a property that is the singleton instance.

I'm not sure if you can expose a singleton directly to COM , I have never
had that case.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Feb 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

26 posts views Thread by Uwe Mayer | last post: by
7 posts views Thread by Tim Clacy | last post: by
10 posts views Thread by E. Robert Tisdale | last post: by
1 post views Thread by Jim Strathmeyer | last post: by
3 posts views Thread by Alicia Roberts | last post: by
5 posts views Thread by Pelle Beckman | last post: by
12 posts views Thread by Preets | last post: by
5 posts views Thread by tobias.sturn | last post: by
3 posts views Thread by stevewilliams2004 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.