473,320 Members | 2,006 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,320 software developers and data experts.

Remoting: No connection could be made because target machine actively

Hi,

I am using remoting to pass in parameters from new launches of an application. So basically I have
only one instance of the application and I am using remoting to pass the parameters.
The problem is as follows:

I can remote call the first few times, but then I get the
"No connection could be made because target machine actively refused it 127.0.0.1:8084"
I don't have a firewall turned on, so I am slightly baffled as to why it would stop working.
I have attached the cut out of the code in question and below is the code used to call the code.
Below code for creating server class
-------------------------------------
RemotingService<ServiceDelegatorMainrs = new RemotingService<ServiceDelegatorMain>();
rs.ServiceCreate();
Delegator = rs.ServerService;
-------------------------------------
Below code for creating client class
-------------------------------------
RemotingClient<IMainrc = new RemotingClient<IMain>(); //Client will only see what the IMain
interface defines.
rc.RemoteService.RemoteServiceMain(args);
-------------------------------------
Now for some unknown reason, the RemotingService class gets deconstructed, before the application
ends. This shouldn't happen. Once the class instance is created it is left alone and should only be
terminated when the application ends.
Nothing touches the instances.
When I run the application through VS2008 everything works fine. Also when run do a ***Debug***
build , it works fine.
ONLY a Release build doesn't work. So that makes it even more confusing.
The remoting code is 100% functioning and the class the receives the remote does nothing now as I
commented the code out. I've created a new skeleton project with the code and that project works
100%..

Why would other forms that have nothing with the class in question affect the outcome.
What gives? I can't help but think this is a VS2008 bug. I have no qualms in releasing a fully
functioning Debug build rather than a none working release.
If you want me to upload a testapplicaiton sample, please let me know and I will.

Any help is much appreciated.
Adhal





#region Remote Server
/// <summary>
/// Server that is going to provide remote services
/// </summary>
/// <typeparam name="T">Definition of the class that is going to registered for remote access.</typeparam>
class RemotingService<Twhere T : MarshalByRefObject, new() //MarshalByRefObject to allow it to be referenced
{
private static TcpChannel _TCPChannel = null;
private T _ServerService = null;
private int _Port = 8084;
private string _ServerName = "GenericRemotingService";

public T ServerService
{
get { return _ServerService; }
set { _ServerService = value; }
}

public int Port
{
get { return _Port; }
set { _Port = value; }
}

public string ServerName
{
get { return _ServerName; }
set { _ServerName = value; }
}

/// <summary>
/// Defaults:
/// P: 8084
/// Server name : GenericRemotingService
/// </summary>
public RemotingService() { }

private void CreateChannel()
{
if (_TCPChannel == null)
{
_TCPChannel = new TcpChannel(8084);
ChannelServices.RegisterChannel(_TCPChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(T), _ServerName, WellKnownObjectMode.SingleCall);
}

}

/// <summary>
/// Default Setting. Creates an instance of T
/// </summary>
public void ServiceCreate()
{
if (_TCPChannel == null)
{
_ServerService = new T();
CreateChannel();
}
}

/// <summary>
/// Server Service instant already exists so just pass refernce
/// </summary>
/// <param name="ServerService">Server Service instant already exists so just pass refernce</param>
public void ServiceCreate(T ServerService)
{
_ServerService = ServerService;
CreateChannel();
}

~RemotingService()
{
if (_TCPChannel != null)
{
_TCPChannel.StopListening(null);
_TCPChannel = null;
}
}
}
#endregion

#region Remote Client
/// <summary>
/// Client that is going to use remote service
/// </summary>
/// <typeparam name="T">Definition of the class registered at the server</typeparam>
class RemotingClient<T>
{
private static string _URL = "tcp://localhost:8084/GenericRemotingService";
private TcpChannel _TCPChannel;
private T _RemoteService;

public T RemoteService
{
get { return _RemoteService; }
}

/// <summary>
/// Default URL "tcp://localhost:8084/GenericRemotingService"
/// Default Uses ServiceDelegateMain
/// </summary>
public RemotingClient() : this(_URL) { }

/// <summary>
///
/// </summary>
/// <param name="URL">Should include port & service name</param>
public RemotingClient(string URL)
{
_URL = URL;

_TCPChannel = new TcpChannel();
ChannelServices.RegisterChannel(_TCPChannel, false);
_RemoteService = (T)Activator.GetObject(typeof(T), _URL);
}

~RemotingClient()
{
if (_TCPChannel != null)
{
_TCPChannel.StopListening(null);
_TCPChannel = null;
}
}
}
#endregion Client
Jun 27 '08 #1
3 3726

"Adhal" <fa**@email.addresswrote in message
news:OY****************@TK2MSFTNGP06.phx.gbl...

<snipped>

Maybe, the asynchronous call has crashed on a thread and you don't know it.
I have seen it where the asynchronous call crashed on a spawned thread, the
application didn't know it and never terminated itself, but it just stopped
functioning.

Jun 27 '08 #2
Mr. Arnold wrote:
Maybe, the asynchronous call has crashed on a thread and you don't know
it. I have seen it where the asynchronous call crashed on a spawned
thread, the application didn't know it and never terminated itself, but
it just stopped functioning.
Thanks Arnold,

I thought it might have been with the asynchronous call so I commented it out. Right now the
remoting part of the application does nothing except call an empty method.

****Also what is bugging more than anything is the Debug version works perfectly, and if I run the
release through VS2008 I get no errors.****

It only occurs on the exe Release build. I have created the project from scratch again and copied in
the code again manually making sure there isn't anything odd. Nothing. The Release should behave in
the same manner as the Debug.

Even when I haven't called the remote service, it closes the Service class sometimes. As though it
times out???

I think I might release the debug version.
???? I'm wearing off my scalp.

Jun 27 '08 #3
???? I'm wearing off my scalp.
>
Finally figured it out. I had the RemotingService declared inside a method. Made it public and tada.
Strange that it should behave differently in debug and simpler applicatons
Jun 27 '08 #4

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

Similar topics

0
by: Karuppasamy | last post by:
H I have created a Windows Application using C#. This Windows application makes a call to a Remoting Object which runs as a Windows Service. This Remoting Component makes a call to a Com+(Name :...
2
by: MS | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
0
by: Maurice | last post by:
Our product is build using the .NET framework 1.1. We have WinForm application that communicates a server via Remoting (tcp channel). We have two ways communication: From application to...
0
by: Data | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
5
by: Data | last post by:
In my project I want to execute some commands on the remote machine. I am using .Net Remoting to achieve this. My server which is an exe is copied on the remote machine and it receives command from...
4
by: M.Perry | last post by:
I am trying to set up two VB.NET Applications. One to sit on the server and run and the other to sit on a client computer and connect to the server application and for the server application to...
8
by: hufaunder | last post by:
I have a website that consumes a webservice. Both of them are in the Default Website folder. I can execute the service without any problem when I go to the test page http://localhost/Service.asmx....
1
by: Derrick | last post by:
Hello all; I'm having a bit of trouble with .NET remoting. Here's my scenario: I have a "remotable" type which is served by a Windows Service. I have a WinForms app which consumes the...
5
by: OJ | last post by:
Hi, I am at a loss here, I have a c# asp.net website which connects to a remote SQL Server 2000 db via a connection string. If I set the website up in the filesystem and use the inbuilt cassini...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.