connecting to CRM error Unable to Login to Dynamics CRMOrganizationWebProxyClient is null

In console app I m trying to connect to CRM but getting this error:

Unable to Login to Dynamics CRMOrganizationWebProxyClient is null OrganizationServiceProxy is nullOrganizationServiceProxy is null 

Strange thing is this code was working fine but just something has happen yesterday and it is not working. CRM instance is same, code is same. No update installed on crm.

Code:

     public static IOrganizationService GetOrganizationService(ref TraceWriter log)
    {

        IOrganizationService _orgService;           
        string connectionstring = "AuthType = Office365; Url = https://mycrm.crm5.dynamics.com/;UserName=me@domain.com;Password=mypassword";
        CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connectionstring);
        _orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
        log.Info($"CRM connection established");           
        return _orgService;
    }

Code do not throw error but from conn I can see internal error.

  • Using Crm.Sdk.CoreAssemblies(9.0.0.7) and XrmTooling.CoreAssembly(9.0.0.7).
  • Target framework 4.6.2

Helplz