In release build the login to a server usually fails 3-4 times before succeding withouth giving any feedback exception.
The code i’m using is:
try
{
var milestoneUri = new UriBuilder(ConnectionReference.Address).Uri;
var userContext = MultiEnvironment.CreateSingleServerUserContext(false, Username, Password, true, milestoneUri);
if (!MultiEnvironment.LoginUserContext(userContext, false, true))
{
var milestoneEx = MultiEnvironment.GetLastException(userContext);
if (milestoneEx != null)
throw new InvalidOperationException($"Handler {ConnectionReference} - ConnectMilestone Fail", milestoneEx);
else
throw new InvalidOperationException($"Handler {ConnectionReference} - ConnectMilestone Fail");
}
Logger.Debug($"Handler {ConnectionReference} - ConnectMilestone - Connected");
}
catch (ServerNotFoundMIPException snfe)
{
Logger.Error($"Handler {ConnectionReference} - ConnectMilestone - Server not found", snfe);
userContext = null;
milestoneUri = null;
throw;
}
catch (InvalidCredentialsMIPException ice)
{
Logger.Error($"Handler {ConnectionReference} - ConnectMilestone - Invalid credentials", ice);
userContext = null;
milestoneUri = null;
throw;
}
catch (Exception)
{
userContext = null;
milestoneUri = null;
throw;
}