ExternalService.AddServer
Registers a server with its service.
Servers must be registered with their services. There has to be at least one server registered for a service in order to be able to execute the service.
A server can be added only once. An attempt to add a server again will lead to an exception. A server cannot be removed during the service's execution or when another server is just being added or removed (e.g. during OnServersChanged call-back to the service).
Adding a server to a service does not make the server active yet. A registered server means it may be used with the service, not that it is going to be automatically used (executed). In order to make a service applicable to its service, the server must set as the active server (or be a part of the set of active servers, in a multi-server service).
Servers can be registered at any time; registering does not need to happen during an application's start-up, but it must happen - naturally - after the respective service has been registered. Since all built-in services are automatically registered during initialization of Revit, their servers can be added as early as during the OnStartup method. Third-party services, on the other hand, get registered during the OnStartup method, therefore their servers need to be added later. The next earliest opportunity for adding servers to a third-party service is on the ApplicationInitialized event.
public void AddServer(
IExternalServer server
)
-
serverThe instance of the server. The server must implement the interface provided by the service.
-
The Server object is not valid or its service Id does not match the service. -or- A server with the same Id has already been registered with the service. -or- The given server does not return valid values from the interface methods. At least one of the Name, VendorId, Description, and ServerId is empty or invalid. -or- The server does not represent a server of a valid type to be used with the service.
-
A non-optional argument was null
-
The operation is not allowed because the service is being executed. -or- The service provider is not valid.