HighTechTalks DotNet Forums  

Re-configuring remoting from config file during application session

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Re-configuring remoting from config file during application session in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
SA
 
Posts: n/a

Default Re-configuring remoting from config file during application session - 12-28-2004 , 10:27 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.



Reply With Quote
  #2  
Old   
Ken Kolda
 
Posts: n/a

Default Re: Re-configuring remoting from config file during application session - 12-28-2004 , 10:36 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


"SA" <informatica (AT) freemail (DOT) nl> wrote

Quote:
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.





Reply With Quote
  #3  
Old   
M.Posseth
 
Posts: n/a

Default Re: Re-configuring remoting from config file during application session - 12-29-2004 , 01:43 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.R egisterChannel(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("RemotingSa mple.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

"SA" <informatica (AT) freemail (DOT) nl> wrote

Quote:
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.





Reply With Quote
  #4  
Old   
SA
 
Posts: n/a

Default Re: Re-configuring remoting from config file during application session - 01-04-2005 , 01:54 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.

"Ken Kolda" <ken.kolda (AT) elliemae-nospamplease (DOT) com> wrote

Quote:
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


"SA" <informatica (AT) freemail (DOT) nl> wrote in message
news:%23Nj68oP7EHA.2196 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
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.







Reply With Quote
  #5  
Old   
SA
 
Posts: n/a

Default Re: Re-configuring remoting from config file during application session - 01-04-2005 , 01:55 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.

"M.Posseth" <michelp (AT) nohausystems (DOT) nl> wrote

Quote:


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.R egisterChannel(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("RemotingSa mple.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

"SA" <informatica (AT) freemail (DOT) nl> wrote in message
news:%23Nj68oP7EHA.2196 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
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.







Reply With Quote
  #6  
Old   
Ken Kolda
 
Posts: n/a

Default Re: Re-configuring remoting from config file during application session - 01-04-2005 , 06:59 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


"SA" <informatica (AT) freemail (DOT) nl> wrote

Quote:
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.

"Ken Kolda" <ken.kolda (AT) elliemae-nospamplease (DOT) com> wrote in message
news:OPns#tP7EHA.2196 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
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


"SA" <informatica (AT) freemail (DOT) nl> wrote in message
news:%23Nj68oP7EHA.2196 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
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.









Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.