Register All the Remotable Classes in an Assembly

Problem

You want to register all the remotable classes that are defined in an assembly without having to specify them in a configuration file.

Solution

Load the assembly with the remotable classes using reflection. Loop through all its types, and use the RemotingConfiguration.RegisterWellKnownServiceType to register every remotable class.

Discussion

.NET makes it equally easy to register remotable classes through a configuration file or programmatically with code. For example, consider the example from recipe Make an Object Remotable. To use programmatic registration, you would first remove the class declarations from the configuration file and leave it as shown here:

<configuration> <system.runtime.remoting> ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.