1

For some reason, this code fails within a console application, but works when running in LinqPad 5:

private static readonly Uri EndpointUri = new Uri(@"obfuscated");
private static readonly string AuthorizationKey = @"obfuscated";

private static void Main(string[] args)
{
    using (var client = new DocumentClient(EndpointUri, AuthorizationKey))
    {
        var database = client.CreateDatabaseQuery()
                             .Where(db => db.Id == "FirstDB")
                             .AsEnumerable()
                             .SingleOrDefault();
    }
}

The error I receive is: Authentication failed because the remote party has closed the transport stream.I have ensured that the Endpoint and AuthKey are identical through copy/pasting (I merely obfuscated it for this question). My only thoughts are that somehow my organization is giving me issues because the uri is https, but I would expect that if it were the case that LinqPad would run into the same problem.

michael
  • 14,844
  • 28
  • 89
  • 177
  • Is there more information passed with the exception? Stacktrace? Other than that, I would try setting a different security protocol to see of that makes a difference, as described at:http://stackoverflow.com/questions/19639846/failure-on-httpwebrequest-with-inner-exception-authentication-failed-because-the – Petar Ivanov Mar 21 '16 at 12:19

0 Answers0