473,549 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2500
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
MarshalByRefObj ect.

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.co m

"Grant Schenck" <sc******@opton line.netwrote in message
news:Oj******** ******@TK2MSFTN GP02.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*******@casp ershouse.com>
To: <sc******@opton line.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
MarshalByRefObj ect.
[GRANT] Are you saying I should derive my Service class from
MarshallByRefOb ject (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.co m

"Grant Schenck" <sc******@opton line.netwrote in message
news:Oj******** ******@TK2MSFTN GP02.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
MarshallByRefOb ject (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
MarshalByRefObj ect. Now, if you are actually passing back your
ServiceBase-derived class, this is fine, since the inheritance chain is
ServiceBase->Component->MarshalByRefOb ject. 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 MarshalByRefObj ect) 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 MarshalByRefObj ect. 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.co m
>
> Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Grant Schenck" <sc******@opton line.netwrote in message
news:Oj******* *******@TK2MSFT NGP02.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
2245
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
1355
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 the case, both web service and application site in same host but serve for different client applications, what is the best way to do it? thanks
2
7268
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 them in a Windows Forms EXE. Create a Windows Forms client and both the Client and the Host EXEs configure the remoting protocols through...
1
1172
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 line at the top of the C++ file (using namespace Shutdown_Restart;) I get something that says a namespace with this name does not exist. Thank you...
2
4419
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 object and a third that connects to the object and waits for events. The error occurs when I try to assign event handlers to the remoted object's...
1
1696
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 credentials to the remoted object, any ideas? If there was no remote layer then I could just do :
7
13965
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 this purpose. For this I registered an object on Service side for Remoting purposes. Remote Object exposes a function named ReloadFiles() that...
4
3983
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 told remoting was the way to go. So I got a client and a server program up and going and from the client I can call a routine in the server...
3
20289
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 a RemotingException of "Failed to connect to an IPC Port: Access is denied". The Access is denied changes if my service isn't running to "The...
0
7446
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1936
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.