473,799 Members | 3,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting Exception

Hi,

I wrote a remoting object and published it like this:

public class RemoteLogger : MarshalByRefObj ect
{
// Contain some methods...
}

public class RemoteManager
{
private TcpChannel m_Channel = null;
private RemoteLogger m_RemoteLogger = null;

public void Initialize(stri ng port)
{
// Registering the channel
BinaryClientFor matterSinkProvi der clientProvider = null;
BinaryServerFor matterSinkProvi der serverProvider = new
BinaryServerFor matterSinkProvi der();
serverProvider. TypeFilterLevel = TypeFilterLevel .Full;
IDictionary APIprops = new Hashtable();
APIprops["port"] = port;
APIprops["name"] = "Logger";
APIprops["typeFilterLeve l"] = TypeFilterLevel .Full;

m_Channel = new TcpChannel(port , clientProvider, serverProvider) ;
ChannelServices .RegisterChanne l(m_Channel);

// Creating a normal local instance of Logger API object and Marshal it.
// This will register the EventsManager as a running singleton object.
// When the clients calls Activator.GetOb ject it will connect to this
running instance.
m_RemoteLogger = new RemoteLogger();
RemotingService s.Marshal(m_Rem oteLogger, "MyLoggerUr i");
}

Other application uses this remote logger fine, But after a while (only a
few minutes) of no activity with this remote logger, and then trying to use
any of its methods cause en exception throwing as follow:

"An unhandled exception of type 'System.Runtime .Remoting.Remot ingException'
occurred in mscorlib.dll
Additional information: Requested Service not found"

As I understand my RemoteLogger life time should be infinite because it was
created by local new and the reference for it never released.

Can anybody tell what is the problem?

Should I add the InitializeLifet imeService() for the RemoteLogger to return
null?

If I do add the InitializeLifet imeService(), how can I free it manually by
code when the RemoteManager whishes to free it?

--------
Thanks
Sharon
Nov 17 '05 #1
7 9548
Hi,

All the Remote objects have a timeout, where they are destroyed if nobody
use them, in order to avoid this override the following function

public override object InitializeLifet imeService()
{
return null;
}

on your RemoteLogger class. This should work
Regards
Salva
"Sharon" wrote:
Hi,

I wrote a remoting object and published it like this:

public class RemoteLogger : MarshalByRefObj ect
{
// Contain some methods...
}

public class RemoteManager
{
private TcpChannel m_Channel = null;
private RemoteLogger m_RemoteLogger = null;

public void Initialize(stri ng port)
{
// Registering the channel
BinaryClientFor matterSinkProvi der clientProvider = null;
BinaryServerFor matterSinkProvi der serverProvider = new
BinaryServerFor matterSinkProvi der();
serverProvider. TypeFilterLevel = TypeFilterLevel .Full;
IDictionary APIprops = new Hashtable();
APIprops["port"] = port;
APIprops["name"] = "Logger";
APIprops["typeFilterLeve l"] = TypeFilterLevel .Full;

m_Channel = new TcpChannel(port , clientProvider, serverProvider) ;
ChannelServices .RegisterChanne l(m_Channel);

// Creating a normal local instance of Logger API object and Marshal it.
// This will register the EventsManager as a running singleton object.
// When the clients calls Activator.GetOb ject it will connect to this
running instance.
m_RemoteLogger = new RemoteLogger();
RemotingService s.Marshal(m_Rem oteLogger, "MyLoggerUr i");
}

Other application uses this remote logger fine, But after a while (only a
few minutes) of no activity with this remote logger, and then trying to use
any of its methods cause en exception throwing as follow:

"An unhandled exception of type 'System.Runtime .Remoting.Remot ingException'
occurred in mscorlib.dll
Additional information: Requested Service not found"

As I understand my RemoteLogger life time should be infinite because it was
created by local new and the reference for it never released.

Can anybody tell what is the problem?

Should I add the InitializeLifet imeService() for the RemoteLogger to return
null?

If I do add the InitializeLifet imeService(), how can I free it manually by
code when the RemoteManager whishes to free it?

--------
Thanks
Sharon

Nov 17 '05 #2
If I do add the InitializeLifet imeService(), how can I free the remote object
manually by code when the RemoteManager whishes to free it?

--------
Thanks
Sharon

Nov 17 '05 #3
Hi,

Where is your remote object? in a windows service? in a webservice? in a
console?

If is a Windows service you can do it stopping the service, manually or by
code.
If is a Webservice you can easily implement a function to dispose the remote
object
If is a console stopping tha app will free it.

Now, if you want to stop it automatically you need to define the Lease of
the object, remember that the Remoting is alive based on the following flow:

1) When the object is called the lease is renewed (it is sponsored)
2) A timer checks when all the sponsors are expired
3) If there are no sponsors the object is disposed
4) Otherwise continue

Check:

ILease lease = (ILease)base.In itializeLifetim eService();
if (lease.CurrentS tate == LeaseState.Init ial)
{
lease.InitialLe aseTime = TimeSpan.FromMi nutes(1);
lease.Sponsorsh ipTimeout = TimeSpan.FromMi nutes(2);
lease.RenewOnCa llTime = TimeSpan.FromSe conds(2);
}

Hope this helps to understand
Overriding the InitializeLifeT ime you are returning infinite timeout
"Sharon" wrote:
If I do add the InitializeLifet imeService(), how can I free the remote object
manually by code when the RemoteManager whishes to free it?

--------
Thanks
Sharon

Nov 17 '05 #4
I'm not sure I fully understand you.

my remote object is as I posted above.
It used inside a .NET DLL used in a Windows application.

Actually I want the remoting object to live during the whole life time of
the application.

So isn't enough just to add the just the InitializeLifet imeService(),
without any sponsor and disposing?

--------------
Thanks again
Sharon
Nov 17 '05 #5
Hi,

Why do you use a remote object within the same appDomain?? Is the same as
using sockets within an app.

If is the same app the problem now is simple, return null on the
InitializeLifet imeService() and your remoting object will be disposed when
you end your application, once the RemoteManager is disposed the channel
registration will be dropped.

Regards
Salva
"Sharon" wrote:
I'm not sure I fully understand you.

my remote object is as I posted above.
It used inside a .NET DLL used in a Windows application.

Actually I want the remoting object to live during the whole life time of
the application.

So isn't enough just to add the just the InitializeLifet imeService(),
without any sponsor and disposing?

--------------
Thanks again
Sharon

Nov 17 '05 #6
No, the local application is holding the remote object so OTHER applications
can invoke method at the local application using this remote object.

I hope I'm more clear now.

So...
If I want the remoting object to live during the whole life time of local
application.
isn't it enough just to add the InitializeLifet imeService() method so it
will return null, without any sponsor and disposing?
Nov 17 '05 #7
Yes,

if its an object you ahve created and remoted via RemotingService s.Marshal or a wellknown singleton object then just return null from InitializeLifet imeServices. But don;t do this for client activated objects.

regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

So...
If I want the remoting object to live during the whole life time of local
application.
isn't it enough just to add the InitializeLifet imeService() method so it
will return null, without any sponsor and disposing?

Nov 17 '05 #8

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

Similar topics

0
2928
by: Sean Newton | last post by:
I am absolutely bewildered by now by the Microsoft.Samples SSPI and Security assemblies. I've been trying to set these up in a very straightforward harness in the way that I'd like to be able to use them. No IIS. Use TCP, binary. Standard server example with a console host and console client. .NET 1.1, windows XP. (I tried posting to the remoting newsgroup, no answers in the last couple days, trying here in hopes that more people watch this...
0
3846
by: Mike Grishaber | last post by:
Hello All, I am using an IHttpAsyncHandler class to intercept HTTP Requests and forward them to a system which processes the Request and returns the Result. I use .NET Remoting to connect the IHttpAsyncHandler object to the System and transfer the Request and Result between the two. This works fine for quite a while, and then I start to get the following error. "This remoting proxy has no channel sink which means either the server has
15
5753
by: Sharon | last post by:
I’m trying to build a generic Publisher-Subscriber that will work over the net, so I’m using the Remoting. I wish that the subscriber user will be notify about the messages sent by the remote publisher, so I used delegate that the user will be able to set on it his own function for that purpuse. The trouble is that this delegate must not be static because there may be many subscribers, and each subscriber may have different...
4
3118
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give it a go). What I want to do is this: Have a server instance of the program, this server instance will receive communication from client programs (as demonstrated in the AddMessage()
1
2693
by: David Krmpotic | last post by:
Hi All! I have a .NET remoting Client-Server application with Server Activated Objects only.. something is worrying me.. sometimes (rarely), I can't connect to the server although it is running. I get the exception saying "A socket operation was attempted to an unreachable host".. it means that it behaves the same as if the server
0
2465
by: Martijn Damen | last post by:
Hi, At the moment I am trying to develop an application that uses another app over .net remoting and having some problems with it (ok, that is ofcourse why I am here), hope somebody can shine a light on the following: I have been given a sample winforms app, which works without problem, I can connect, send queries and become response from the other application. When I try to implement this in webforms, this unfortunately does not...
4
2267
by: Sharon | last post by:
Hi, I'm using the remoting, and I have a remoting object that has a public event that other processes should register to it. But when the client process is registering to the remote event, it throw the following exception: System.Runtime.Serialization.SerializationException {“Cannot find the assembly Tester, Version=1.0.2164.27180, Culture=neutral, PublicKeyToken=null.”}
3
424
by: Mike9900 | last post by:
We need to get the correct error message from the .NET Remoting server on the another computer. When we use .NET Remoting the client does not receive correct SQL Server error message if the client is on the another computer. For example, if the client deleted a record in SQL Server and the SQL Server throw and exception, the exeption message is not sent to the client as the correct SQL Server message, instead the exception is either...
0
3404
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false); I get the following error - doesn't matter if I try it local from my machine or from a remote machine. (After the Errormessage is more text ;))
0
1580
by: senpark15 | last post by:
Hi EveryBody, I am developing .net remoting application.I have Created server and client application. Server has installed on Two Pc's and cliient have to connect two Pc's and do some functions. Its working Fine on local machine . But when i tried to connect two PC's, its through an remoting exception This is my server code: Dictionary<string, object> props = new Dictionary<string, object>(); props = "Full";
0
9538
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7563
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
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
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.