Groups | Blog | Home
all groups > dotnet remoting > december 2004 >

dotnet remoting : Re-configuring remoting from config file during application session



Ken Kolda
12/28/2004 8:36:19 AM
As you noted, the config file should only be read once prior to attempting
to create any remote objects. Usually it is sufficient to read the file as
part of the application startup (i.e. in Main() prior to starting your
application logic). Then you'll be guaranteed that whenever you use remoting
in your app, the framework will be ready. Is there any reason this wouldn't
be appropriate for what you're doing?

Ken


[quoted text, click to view]

SA
12/28/2004 10:27:28 AM
Hi all,

I am fairly new to remoting.

I have successfully set up a remoting Winforms client that communicates over
TCP (binary) with a Windows Service.

The nature of the project is such that we may have to communicate with 2 or
more services. The URIs are provided to the program by the user, but the
channel and formatter info is in the config file.

Adding the first URI is not a problem: I read the config file and then
create the object using System.Activator.GetObject. However, for the second
URI, when I read the config file, I get an error message stating that the
application name has already been set.

The easy solution seems to me to check whether remoting has already been
configured, but I can't find out how to do that.

Any help is appreciated.

---

Sven.

M.Posseth
12/29/2004 8:43:41 AM



Well i encountered a simular problem when i didn`t knew exactly what the
server `s ip / name or port is

as my program is beeing shipped to customers i do not know how and on wich
computer the server is configured

so instead of the need to change the config file and restart the app every
time , i came up with this solution

VB.NET Code ::::::::
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(New
System.Runtime.Remoting.Channels.Tcp.TcpChannel)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Try

cRemote = CType(Activator.GetObject(Type.GetType("RemotingSample.NHSBL,
RemoteBL"), "tcp://" & TextBox1.Text & ":" & NumericUpDown.Value.ToString()
& "/NHSBL"), RemotingSample.NHSBL)

cRemote.NewClient()

Catch ex As Exception

Label2.Text = "Could not connect to the service ! " & vbCrLf & "are you sure
the service is running ? "

Label2.Visible = True

Beep()

Exit Sub

End Try

blnConnected = True

End Sub


in textbox1 the user can enter the ip or servername and try to connect to
the service


i am currently bussy to find a way that i can do a broadcast on the network
to discover the availlable running servers so the user can make a selection
in a drop down list ( see my previous post ) however it seems i am
inventing the weel ( again ??? )



Met vriendelijke groet
Kind regards,

Michel Posseth
Software Developer
Microsoft Certified Professional

Company : Nohau Systems B.V.
Division : Systems Development

[quoted text, click to view]

SA
1/4/2005 1:54:51 PM
Hi Ken:

Thanks for the reply.

Yes, I need to be able to configure connections to two different servers for
the same object ;o)

I guess that's not likely to happen with remoting.

--

---

Sven.

[quoted text, click to view]

SA
1/4/2005 1:55:43 PM
Michel:

Bedankt ;o)

I'll have to do something similar I guess...

The other issue I am having is that, ideally, I would be able to connect to
two different servers remoting the same object type, at the same time...

My app supports SOAP over TCP and SOAP over HTTP and binary RPC, all at the
same time, etc.

--

---

Sven.

[quoted text, click to view]

Ken Kolda
1/4/2005 4:59:28 PM
In that case you should not use the config files at all. Use
Activator.GetObject() to fetch your remote object -- you will then specify
the URL with each invocation so you can fetch the object from any number of
servers during the lifetime of your application. The config file approach to
defining your remote objects is not meant for cases where you're switching
servers on the fly like this.

Ken


[quoted text, click to view]

AddThis Social Bookmark Button