473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Singleton object across processes.

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

Sep 27 '05 #1
3 1493
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.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<Ro*********@gmail.com> wrote in message news:11*********************@g14g2000cwa.googlegro ups.com...
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

Sep 27 '05 #2
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/arch...18/159479.aspx

Rob

Sep 28 '05 #3
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/de...asp?frame=true

Examples:
http://msdn.microsoft.com/library/de...asp?frame=true

Assymetric Encryption Channel Sink:
http://msdn.microsoft.com/msdnmag/is...6/NETRemoting/
Hope it helps ;)

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
<Ro*********@gmail.com> wrote in message news:11**********************@o13g2000cwo.googlegr oups.com... 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/arch...18/159479.aspx

Rob

Sep 28 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rajarshi Guha | last post by:
Hi, I'm having a little problem with understanding the working of a singleton and borg class. Basically I nedd an class whose state will be shared across several modules. I found the stuff on the...
1
by: Richard A. DeVenezia | last post by:
foo() generates elements with event handlers that invoke foo function properties. Is this an abhorrent or misthought pattern ? It allows just the one occurence of identifier /foo/ to be changed...
2
by: Rick | last post by:
A coworker has brought up the following quote from a book as confirmation that we cannot use Singletons in ASP.Net application code, at least at the ASP.Net tier. I am looking for references to...
3
by: Jeremy Cowles | last post by:
Will the keyword "Me" ever be able to be the target of an assignment? Because singleton classes would be MUCH simplier if you could just point Me to a different address. For example: Class...
3
by: Rob.J.White | last post by:
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....
2
by: Kevin Newman | last post by:
I have been playing around with a couple of ways to add inheritance to a JavaScript singleton pattern. As far as I'm aware, using an anonymous constructor to create a singleton does not allow any...
7
by: John A Grandy | last post by:
For a singleton class utilizes by ASP.NET 2.0 page processing: When initial instantiation is performed during the initial call to the retrieve instance method (let's call the method...
7
by: fredd00 | last post by:
Hi I'm just starting with singleton and would like to implement in my new web app. I have a question lets say i create a singleton DataHelper that holds a static SqlConnection object to...
9
by: oleggus | last post by:
I hope, I misunderstood some basics here and it is easy to solve.. I need a singleton object running on server which can be used(write and read) by different client interfaces - for example there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.