473,395 Members | 1,679 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,395 software developers and data experts.

Getting at Service object from remoted object?

Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
server and I can, via an IPC Channel, expose methods and call them from a
client. However, I now want my remoted object to be able to invoke a method
on my server object and given that the object is built in a C# Class DLL
shared between the client and server I'm not sure how to get access to the
server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck
Sep 13 '06 #1
3 2490
Grant,

The object you expose through remoting is an object, nothing more,
nothing less. To that end, you can expose properties, methods, fields, etc,
etc, that will allow it to access the server, assuming that your object has
a reference to it.

So how does your object get access to the server? This is the same as
asking how a form has access to another form. You set a reference through a
method, the constructor, a field, or a property.

The only consideration here is that if you expose a property with your
service object through remoting, is it going to be marshaled by value, or by
reference? Something tells me you will want it to be marshaled by
reference, in which case you will want to derive your server class from
MarshalByRefObject.

Not seeing your service object design, I can't tell if it is a good idea
to expose the whole object. You might be exposing things you don't want to.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Grant Schenck" <sc******@optonline.netwrote in message
news:Oj**************@TK2MSFTNGP02.phx.gbl...
Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
server and I can, via an IPC Channel, expose methods and call them from a
client. However, I now want my remoted object to be able to invoke a
method on my server object and given that the object is built in a C#
Class DLL shared between the client and server I'm not sure how to get
access to the server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck


Sep 13 '06 #2
Hi,

See below.

Thanks, Grant Schenck

----- Original Message -----
From: "Nicholas Paldino [.NET/C# MVP]" <ca*******@caspershouse.com>
To: <sc******@optonline.net>
Sent: Wednesday, September 13, 2006 8:41 AM
Subject: Re: Getting at Service object from remoted object?

Grant,

The object you expose through remoting is an object, nothing more, nothing
less. To that end, you can expose properties, methods, fields,
etc, etc, that will allow it to access the server, assuming that your
object
has a reference to it.
[GRANT] Right, I need a reference to my Service object.
So how does your object get access to the server? This is the same
as asking how a form has access to another form. You set a reference
through a method, the constructor, a field, or a property.
[GRANT] If I create a form from one form, I can pass the first form to the
second form. However, the remoting object isn't created until the client
invokes the remoted object method so I'm confused as to how the server could
get access to the object between when it is created and when the method is
invoked. Part of my confusion is I'm not clear how my remoted object, built
as a C# DLL class, can be able to call methods in my Service object.
The only consideration here is that if you expose a property with
your service object through remoting, is it going to be marshaled by
value,
or by reference? Something tells me you will want it to be marshaled by
reference, in which case you will want to derive your server class from
MarshalByRefObject.
[GRANT] Are you saying I should derive my Service class from
MarshallByRefObject (as well as ServiceBase) and somehow this object would
be a singleton for all clients, i.e., my remoted object IS my service???
Not seeing your service object design, I can't tell if it is a good
idea to expose the whole object. You might be exposing things you don't
want
to.
[GRANT] Actually I don't. My goals seem simple.

- I have a service running (controls a phone system but not particularly
relevent)
- I want to remote a single method (MakeCall)
- Client applications will invoke this method and pass a few parameters.
- Service will "get" these requests, presumably each on its own thread and
able to overlap, and via appropirate protection, service the request.
- Serving the request takes real time so using IPC (thanks from yesterday!)
the method blocks waiting for the async work to complete.
- At some point the work completes and the service will then release the
client method call thread and let it return the results.

So, I only want to expose one method from my server.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Grant Schenck" <sc******@optonline.netwrote in message
news:Oj**************@TK2MSFTNGP02.phx.gbl...
>Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
>server and I can, via an IPC Channel, expose methods and call them
from a
>client. However, I now want my remoted object to be able to invoke a
method on my server object and given that the object is built in a C#
Class DLL shared between the client and server I'm not sure how to get
>access to the server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck

Sep 13 '06 #3
Grant,
[GRANT] If I create a form from one form, I can pass the first form to the
second form. However, the remoting object isn't created until the client
invokes the remoted object method so I'm confused as to how the server
could
get access to the object between when it is created and when the method is
invoked. Part of my confusion is I'm not clear how my remoted object,
built
as a C# DLL class, can be able to call methods in my Service object.
Certainly your remoted object has access to static properties/fields in
the same app domain, right? =)
[GRANT] Are you saying I should derive my Service class from
MarshallByRefObject (as well as ServiceBase) and somehow this object would
be a singleton for all clients, i.e., my remoted object IS my service???
If you expose your service object from your remoted object, then there
are two things that can happen. A serialized instance of the service object
could be passed back to the caller, and the caller can make calls on that.
The problem with this is that the calls occur in the client's app domain,
which is not what I think you want.

The second part is to have the service object derive from
MarshalByRefObject. Now, if you are actually passing back your
ServiceBase-derived class, this is fine, since the inheritance chain is
ServiceBase->Component->MarshalByRefObject. Calls made in the client's app
domain will be marshaled back to the app domain of the service.

I really wouldn't expose the service base here. If anything, I would
expose another object (which derives from MarshalByRefObject) which exposes
the functionality you need.
[GRANT] Actually I don't. My goals seem simple.

- I have a service running (controls a phone system but not particularly
relevent)
- I want to remote a single method (MakeCall)
- Client applications will invoke this method and pass a few parameters.
- Service will "get" these requests, presumably each on its own thread and
able to overlap, and via appropirate protection, service the request.
- Serving the request takes real time so using IPC (thanks from
yesterday!)
the method blocks waiting for the async work to complete.
- At some point the work completes and the service will then release the
client method call thread and let it return the results.

So, I only want to expose one method from my server.
If this is the case, have your object that exposes this method derive
from MarshalByRefObject. Also, you might want to make it a per-call
service, meaning your object is instantiated and then destroyed for each
call.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
>
> Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Grant Schenck" <sc******@optonline.netwrote in message
news:Oj**************@TK2MSFTNGP02.phx.gbl...
>>Hello,

I have a Windows Service developed in C# .NET. I'm making it a remote
>>server and I can, via an IPC Channel, expose methods and call them
from a
>>client. However, I now want my remoted object to be able to invoke a
method on my server object and given that the object is built in a C#
Class DLL shared between the client and server I'm not sure how to get
>>access to the server object from the remoted object.

So, what techniques are commonly used to allow this?

Thanks,
--
Grant Schenck


Sep 13 '06 #4

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

Similar topics

11
by: Michael Riggio | last post by:
Is there a way to have a windows service instantiate a class that is a web service, which will then be accessible to clients via HTTP? Thanks, -Mike
1
by: pei_world | last post by:
by default, A web service sit in (Host A). if other application that sit in (Host B) want to use that web Service, then need to add web reference to it using HTTP TCP/IP protocol. but how about...
2
by: Fadi | last post by:
Backround: I am trying to figure out how to do the equivalant of a classic COM Local Server Singleton in .NET/C#. I created a coupld of simple Class Libs that exposes public interfaces and hosted...
1
by: Tressa | last post by:
I have a C# Windows Service and I need to access it from a C++ Application. I am new to programming and have been looking all over for help on the internet without much luck. I did place this...
2
by: Dan | last post by:
I am having a problem trying to assign event handlers to the events of a remoted object. I have one program that registers the object for remoting, Another that connects and calls methods on the...
1
by: Steve Drake | last post by:
All, I have a WEBPAGE that needs to pass the current credentials to a .NET remoted object so this can pass the credentials to a SOAP WEBSERVICE (All written in C#) But I cannot see how I pass...
7
by: Ahmad Jalil Qarshi | last post by:
Hi! I want to develop two applications one a Windows Service and the other a GUI based application. I want some sort of communication between Service and GUI. I have decided to use Remoting for...
4
by: WinDev | last post by:
We are trying to build a system where we have a Windows Service do some manipulation of data, and then sending the data to a Windows App. I had posted a question of how we should do this and was...
3
by: Grant Schenck | last post by:
I have a simple remoting sample using IPCChannel. If I run the server code as a console app my client can connect just fine. However, if I the same server code runs in a service, the client gets...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.