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 / December 2004

Tip: Looking for answers? Try searching our database.

Initiating a TcpChannel with programmatic IDcitionary

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt Kosorok - 29 Dec 2004 17:17 GMT
I need to be able to set both the port and typeFilterLevel for my remoting
object.  Here's my IDictionary code:

IDictionary props = new Hashtable() ;
props["port"] = nTcpPort ;
props["typeFilterLevel"] = "Full" ;
BinaryServerFormatterSinkProvider formatterProvider = new
BinaryServerFormatterSinkProvier( props, null ) ;

That's what the articles I read said to do to avoid that annoying security
exception.  I want to know create a TcpChannel object that then provides this
object using RemotingServices.Marshal(), so I can then use
RemotingServices.Disconnect() when the time comes to stop the remote object.  
I also need to make sure the object is in Singleton mode.

The books I have don't really cover any of this.  I'm sure there's something
on the client side I'm going to have to pay attention ( especially if I want
bidirectional communication between the server and the client ).  Anyone have
a good resource on how to do this all programmatically?
Signature


- Matt Kosorok

Ken Kolda - 29 Dec 2004 23:49 GMT
See comments inline below...

> I need to be able to set both the port and typeFilterLevel for my remoting
> object.  Here's my IDictionary code:
[quoted text clipped - 4 lines]
> BinaryServerFormatterSinkProvider formatterProvider = new
> BinaryServerFormatterSinkProvier( props, null ) ;

That's not quite right -- the port is a property of the channel, not of the
formatter sink. The code should look like:

BinaryServerFormatterSinkProvider formatterProvider = new
BinaryServerFormatterSinkProvider() ;
formatterProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable() ;
props["port"] = nTcpPort ;
TcpChannel chan = new TcpChannel(props, null, formatterProvider);

> That's what the articles I read said to do to avoid that annoying security
> exception.  I want to know create a TcpChannel object that then provides this
> object using RemotingServices.Marshal(), so I can then use
> RemotingServices.Disconnect() when the time comes to stop the remote object.
> I also need to make sure the object is in Singleton mode.

When you use RemotingServices.Marhshal(), you are effectively creating a
Singleton. The only way to create a SingleCall SAO is via a config file or
using RemotingConfiguration.RegisterWellKnownServerObject().

> The books I have don't really cover any of this.  I'm sure there's something
> on the client side I'm going to have to pay attention ( especially if I want
> bidirectional communication between the server and the client ).  Anyone have
> a good resource on how to do this all programmatically?

You're on the right track. Just register your channel in the exact same way
on the client but use 0 for the port number. Then, to fetch your singletons,
use Activator.GetObject(). Just be aware that if you're going to be calling
RemotingServices.Disconnect() on the object within the server that any
client code that attempts to access the object from that point on will fail,
so make sure the necessary exception handling is present.

Ken

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.