Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / November 2005

Tip: Looking for answers? Try searching our database.

Single instance apps and remoting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
davem - 15 Nov 2005 18:21 GMT
Hi,

We've got a c# application that uses remoting, and everything was working.
We needed to make the client a single instance application, and to do we used
WindowsFormsApplicationBase, as described in the article
http://msdn.microsoft.com/msdnmag/issues/05/09/NETMatters/default.aspx

Internally WindowsFormsApplicationBase uses remoting to pass command line
args to the running local instance, using TcpChannel. Our code then started
RemotingException "The channel 'tcp' is already registered.".

I've named the new TcpChannel we're creating so the exception is no longer
thrown, but, when I try and use the proxy returned by Activator.GetObject I'm
getting a SocketException "An existing connection was forcibly closed by the
remote host". I also get the same error if I don't register an additional
TcpChannel. So, I'm guessing that Activator.GetObject is always using the
channel created by WindowsFormsApplicationBase (i think this is a secure
connection, hence the exception), and not the one we're creating.

If this is the case, how do I create the object using the right channel?
otherwise, what am I doing wrong?

I've tried to include some stripped down code below...

Thanks,

// The channel is registered on client as follows...
BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();

IDictionary properties = new Hashtable();
properties["name"] = string.Empty;
TcpChannel channel = new TcpChannel(properties, clientProv, serverProv);

ChannelServices.RegisterChannel(channel, false);

// Proxy is created as follows...
string url = string.Format(CultureInfo.InvariantCulture, "tcp://{0}:{1}/TX",
Host, Port);
(ITX)Activator.GetObject(typeof(ITX), url);

// The channel is registered on server (where TXServer implements ITX)
TcpChannel channel = new TcpChannel(Port);
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
RemotingConfiguration.RegisterWellKnownServiceType(typeof(TXServer), "TX",
WellKnownObjectMode.Singleton);
ChannelServices.RegisterChannel(channel, false);
Grumpy1 - 23 Nov 2005 19:15 GMT
Have you founda solution to this problem yet. I'm having the same issue.

> Hi,
>
[quoted text clipped - 48 lines]
> WellKnownObjectMode.Singleton);
> ChannelServices.RegisterChannel(channel, false);
davem - 25 Nov 2005 11:14 GMT
Hi,

The TcpChannel created internally is given the default priority. I create
our additional channel with a higher priority, which seems to solve the
problem. I'm not sure this is a proper fix, but it seems to work.

System.Collections.IDictionary properties = new
System.Collections.Hashtable();
properties["name"] = string.Empty;
properties["priority"] = "10";

channel = new TcpChannel(properties, clientProv, serverProv);

> Have you founda solution to this problem yet. I'm having the same issue.
>
[quoted text clipped - 50 lines]
> > WellKnownObjectMode.Singleton);
> > ChannelServices.RegisterChannel(channel, false);

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.