Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to change remote service on runtime?

How to change remote service on runtime?

Scheduled Pinned Locked Moved ASP.NET
questioncsharpdesignsysadminhelp
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qin Yan
    wrote on last edited by
    #1

    am doing a server-client project using .NET remoting. The server application are installed on 2 servers (exactly the same). I used "singleton" type on the remote object. When a client application starts, it uses the 1st server as primary and build a TCP channel with it. The code is: TcpChannel channel = new TcpChannel(port); ChannelServices.RegisterChannel(channel); WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry( typeof(myRemoteObj), RmtObjUrl); RemotingConfiguration.RegisterWellKnownClientType(entry); Everything goes smoothly till now. But my design is, if the server goes down, client should be able to switch to the other server without closing and re-opening. I used the same code to register the 2nd server, showing as blow: WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry( typeof(myRemoteObj), new_RmtObjUrl); RemotingConfiguration.RegisterWellKnownClientType(entry); The value of "new_RmtObjUrl" now is the 2nd server's location and port. The error occurs at : RemotingConfiguration.RegisterWellKnownClientType(entry); Error message is: An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll Additional information: Attempt to redirect activation of type 'myRemoteObj, myRemoteObj' which is already redirected. How can i un-register the privous activation of "myRemoteObj"? Or is there anyway to build a new channel to the 2nd server? Thanks in advance on your kindly follow up! I have been stick on it for the whole night :(

    N 1 Reply Last reply
    0
    • Q Qin Yan

      am doing a server-client project using .NET remoting. The server application are installed on 2 servers (exactly the same). I used "singleton" type on the remote object. When a client application starts, it uses the 1st server as primary and build a TCP channel with it. The code is: TcpChannel channel = new TcpChannel(port); ChannelServices.RegisterChannel(channel); WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry( typeof(myRemoteObj), RmtObjUrl); RemotingConfiguration.RegisterWellKnownClientType(entry); Everything goes smoothly till now. But my design is, if the server goes down, client should be able to switch to the other server without closing and re-opening. I used the same code to register the 2nd server, showing as blow: WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry( typeof(myRemoteObj), new_RmtObjUrl); RemotingConfiguration.RegisterWellKnownClientType(entry); The value of "new_RmtObjUrl" now is the 2nd server's location and port. The error occurs at : RemotingConfiguration.RegisterWellKnownClientType(entry); Error message is: An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll Additional information: Attempt to redirect activation of type 'myRemoteObj, myRemoteObj' which is already redirected. How can i un-register the privous activation of "myRemoteObj"? Or is there anyway to build a new channel to the 2nd server? Thanks in advance on your kindly follow up! I have been stick on it for the whole night :(

      N Offline
      N Offline
      Natty Gur
      wrote on last edited by
      #2

      Qin hi, You might use Activator :

      SessionInterface.ITryClass oObj = (SessionInterface.ITryClass)Activator.GetObject( typeof(SessionInterface.ITryClass),"tcp://localhost:1967/TcpSession");

      Q 1 Reply Last reply
      0
      • N Natty Gur

        Qin hi, You might use Activator :

        SessionInterface.ITryClass oObj = (SessionInterface.ITryClass)Activator.GetObject( typeof(SessionInterface.ITryClass),"tcp://localhost:1967/TcpSession");

        Q Offline
        Q Offline
        Qin Yan
        wrote on last edited by
        #3

        Yes! It works! Thanks a lot!:)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups