Add server not working in plugin.

 if (server.StartsWith("http://") == false && server.StartsWith("https://") == false)
{
 server = "http://" + server;
}
     Uri uri = new Uri(server); 
 
CredentialCache _credentialCache = Util.BuildCredentialCache(uri, username, password,"Negotiate");
 
 VideoOS.Platform.SDK.Environment.AddServer(false, uri, _credentialCache);
 
 VideoOS.Platform.SDK.Environment.Login(uri, IntegrationId, IntegrationName, Version, ManufacturerName);
 
 
 
 List<Item> items = Configuration.Instance.GetItems(ItemHierarchy.SystemDefined);

I am want to add another server to my plugin. when i add another server using this code It is not adding

If I use VideoOS.Platform.SDK.Environment.Initialize(); It Adds new server but Smart client shows following exception

************** Outer Exception **************

Exception type:System.InvalidCastException

Exception message:Unable to cast object of type ‘VideoOS.Platform.SDK.Platform.SDKEnvironmentManager’ to type ‘VideoOS.RemoteClient.Application.MIP.Manager.SCEnvironmentManager’.

Exception source:VideoOS.RemoteClient.Application

Exception Target Site: GetSidePanelPlugins

at VideoOS.RemoteClient.Application.UI.Panels.ViewModels.PlatformPanelViewModel.GetSidePanelPlugins()

at VideoOS.RemoteClient.Application.UI.Panels.ViewModels.PlatformPanelViewModel.UpdateControls()

at System.EventHandler`1.Invoke(Object sender, TEventArgs e)

at VideoOS.RemoteClient.Application.Controllers.WorkSpace.WorkSpaceController.FireWorkSpaceChanged(WorkSpaceItem workSpace, Boolean isFromLocalSource)

at VideoOS.RemoteClient.Application.Controllers.WorkSpace.WorkSpaceController.SetWorkSpace(WorkSpaceItem item, Boolean setNewView, IList`1 viewItemStates, Boolean setVideoWall, Boolean notifyListeners, Boolean isFromLocalSource)

at VideoOS.RemoteClient.Application.Controllers.WorkSpace.WorkSpaceController.SetWorkSpace(Guid workSpaceId, Boolean setNewView, IList`1 viewItemStates, Boolean notifyListeners, Boolean isFromLocalSource)

at VideoOS.RemoteClient.Application.UI.WorkspaceTab.WorkSpaceTabViewModel.AsyncChangeWorkspace(WorkSpaceItem oldWorkspaceItem)

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

You should never reference the VideoOS.Platform.SDK in a plugin. The purpose of VideoOS.Platform.SDK is to provide the functionality that you get from environment (in this case the Smart Client) when you do not have a base environment but instead develop a standalone application.

You cannot do this within a plugin.

In the Smart Client environment you have sites it is logged into from the initial login dialog, this can be multiple sites in case that Milestone Federated Architecture (MFA) is used, but not multiple sites that are not otherwise related.

Ok thanks.