Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / September 2005

Tip: Looking for answers? Try searching our database.

Singleton object across processes.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob.J.White@gmail.com - 27 Sep 2005 15:53 GMT
Hello,
I'm stuck, essentially I have a c# object that is visible to COM and
to other .net applications. The object in question provides
communications between machines for reporting an the like. Essentially
the problem is that because of a Socket.Bind() call I can only have one
instance of the object in existence on a PC at any given time. I'm
trying to find a way that I can allow both COM and .net clients access
to the same object, but from different processes.
I tried using a windows service, but that's no good as it won't
allow COM interoperability. I looked at object pooling, but I know
little to nothing about the subject and it didn't really seem to be
what I wanted.
Is there a way that I can have the object accessible to all clients? Or
am I essentially trying to do something impossible?
Thanks for any help.
Rob
Dave - 27 Sep 2005 17:13 GMT
Try using System.Runtime.Remoting.

Register a Channel using ChannelServices, then register a remotable Type (derives from MarshalByRefObject) using
RemotingConfiguration.

I suggest writing a managed library that the COM app can use to connect to the remoted object.  In other words, register a managed
object for COM interop that can consume the remoted object and serve as the interface from the COM world to the .NET remoting world.

Signature

Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------

> Hello,
> I'm stuck, essentially I have a c# object that is visible to COM and
[quoted text clipped - 12 lines]
> Thanks for any help.
> Rob
Rob.J.White@gmail.com - 28 Sep 2005 09:32 GMT
Dave,
I thought about that, but it seems like a lot of hops to make a local
method call. That said I may well end up going that way, for now I'm
going to try something like this...

http://blogs.msdn.com/adioltean/archive/2004/06/18/159479.aspx

Rob
Dave - 28 Sep 2005 17:13 GMT
Interesting blog entry, but it seems the first paragraph may be a bit misleading...

.NET remoting does work with a Window's Service.
.NET remoting doesn't offer a secure channel, but does provide a sink chain that you can "plug" into to perform encryption and
decryption, using System.Security.Cryptography, on the raw network stream.  There is an MSDN article that explains exactly how to do
this in the most basic fashion. See below for the link.

> it seems like a lot of hops to make a local
> method call.

I had assumed that you weren't making a local call since you were using a Socket as you mentioned in your original post.   If it's a
local call, service and client code is executing in the same AppDomain, then you don't need remoting or DCOM.

Here are some links for Remoting in case you decide to go that route (watch for wrapping):

.NET Remoting:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/i
ntroremoting.asp?frame=true


Examples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conremotingexampleasynchronousremoting.asp?frame=true


Assymetric Encryption Channel Sink:
http://msdn.microsoft.com/msdnmag/issues/03/06/NETRemoting/

Hope it helps ;)

Signature

Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------

> Dave,
> I thought about that, but it seems like a lot of hops to make a local
[quoted text clipped - 4 lines]
>
> Rob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.