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. General Programming
  3. C#
  4. Unregister Server Activated Object ?

Unregister Server Activated Object ?

Scheduled Pinned Locked Moved C#
sysadminalgorithmshelpquestion
3 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    Stefan Troschuetz
    wrote on last edited by
    #1

    I use remoting in my application, which proofed to be very useful but now i have a small problem. In the server application the remote object is register as an available service in singleton mode. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "Server", WellKnownObjectMode.Singleton ); Now I'm searching a way to unregister it in the server application, so no remote calls from clients are processed?

    H 1 Reply Last reply
    0
    • S Stefan Troschuetz

      I use remoting in my application, which proofed to be very useful but now i have a small problem. In the server application the remote object is register as an available service in singleton mode. RemotingConfiguration.RegisterWellKnownServiceType( typeof(RemoteObject), "Server", WellKnownObjectMode.Singleton ); Now I'm searching a way to unregister it in the server application, so no remote calls from clients are processed?

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      If you use a configuration file to publish the types you want remoted, you can use the RemotingServices.Disconnect to stop the object from receiving further messages. See the documentation for that method for more information. The only other way is to stop the AppDomain in which the WKO is registered. If you're using a Windows Service, you can stop the service both manually using the Services snap-in or the ServiceController class. If you're hosting this in another process, you could create a separate AppDomain and launch an executable that registers the WKO, then when you want to stop it unload the AppDomain using AppDomain.Unload. One more way that wouldn't unregister the WKO but would keep it from processing requests (which I wouldn't recommend because clients will still see the published WKO) would be to put the interface in a shared library and the implementation of that on the server. Have an internal method that you can call that could do something like set a flag. In each of your interface implementation methods / properties, check that flag and either don't return anything or throw some sort of exception, like NotSupportedException or something. The first two methods are more complete, IMO.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      S 1 Reply Last reply
      0
      • H Heath Stewart

        If you use a configuration file to publish the types you want remoted, you can use the RemotingServices.Disconnect to stop the object from receiving further messages. See the documentation for that method for more information. The only other way is to stop the AppDomain in which the WKO is registered. If you're using a Windows Service, you can stop the service both manually using the Services snap-in or the ServiceController class. If you're hosting this in another process, you could create a separate AppDomain and launch an executable that registers the WKO, then when you want to stop it unload the AppDomain using AppDomain.Unload. One more way that wouldn't unregister the WKO but would keep it from processing requests (which I wouldn't recommend because clients will still see the published WKO) would be to put the interface in a shared library and the implementation of that on the server. Have an internal method that you can call that could do something like set a flag. In each of your interface implementation methods / properties, check that flag and either don't return anything or throw some sort of exception, like NotSupportedException or something. The first two methods are more complete, IMO.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        Thanks for info! I'm now using this code in my server application and it functions very well. this.remoteObject = new RemoteObject(); System.Runtime.Remoting.RemotingServices.Marshal(this.remoteObject, "Server"); System.Runtime.Remoting.RemotingServices.Disconnect(this.remoteObject);

        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