{"action":"closed","issue":{"url":"https://api.github.com/repos/NuGet/Home/issues/2043","repository_url":"https://api.github.com/repos/NuGet/Home","labels_url":"https://api.github.com/repos/NuGet/Home/issues/2043/labels{/name}","comments_url":"https://api.github.com/repos/NuGet/Home/issues/2043/comments","events_url":"https://api.github.com/repos/NuGet/Home/issues/2043/events","html_url":"https://github.com/NuGet/Home/issues/2043","id":130859076,"number":2043,"title":"NullReference when trying to download a package with NuGet.Client","user":{"login":"twsouthwick","id":583206,"avatar_url":"https://avatars.githubusercontent.com/u/583206?v=3","gravatar_id":"","url":"https://api.github.com/users/twsouthwick","html_url":"https://github.com/twsouthwick","followers_url":"https://api.github.com/users/twsouthwick/followers","following_url":"https://api.github.com/users/twsouthwick/following{/other_user}","gists_url":"https://api.github.com/users/twsouthwick/gists{/gist_id}","starred_url":"https://api.github.com/users/twsouthwick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twsouthwick/subscriptions","organizations_url":"https://api.github.com/users/twsouthwick/orgs","repos_url":"https://api.github.com/users/twsouthwick/repos","events_url":"https://api.github.com/users/twsouthwick/events{/privacy}","received_events_url":"https://api.github.com/users/twsouthwick/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-02T23:54:42Z","updated_at":"2016-02-04T02:38:42Z","closed_at":"2016-02-04T02:38:42Z","body":"I'm using NuGet.Client libraries 3.3 to get the latest version of a library and download it. I'm using the following code:\r\n\r\n```csharp\r\nusing NuGet.Protocol.Core.Types;\r\nusing NuGet.Protocol.Core.v3;\r\nusing NuGet.Protocol.Core.v3.RemoteRepositories;\r\nusing NuGet.Versioning;\r\nusing System.Linq;\r\nusing System.Net.Http;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace nuget_core_null_ref\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            RunAsync(\"https://api.nuget.org/v3/index.json\", \"NuGet.Client\").Wait();\r\n        }\r\n\r\n        private static async Task RunAsync(string feed, string name)\r\n        {\r\n            var handler = new HttpClientHandler();\r\n            var httpResource = new HttpHandlerResourceV3(handler, handler);\r\n\r\n            var repo = Repository.Factory.GetCoreV3(feed);\r\n            var finder = new RemoteV3FindPackageByIdResource(repo, () =>\r\n            {\r\n                return Task.FromResult<HttpHandlerResource>(httpResource);\r\n            });\r\n\r\n            var versions = await finder.GetAllVersionsAsync(name, CancellationToken.None);\r\n            var latest = versions.OrderByDescending(v => v.Version).First();\r\n\r\n            await GetPackageSizeAsync(finder, latest, name);\r\n        }\r\n\r\n        private static async Task GetPackageSizeAsync(FindPackageByIdResource finder, NuGetVersion latest, string name)\r\n        {\r\n            // Exception thrown on the following line\r\n            using (var stream = await finder.GetNupkgStreamAsync(name, latest, CancellationToken.None))\r\n            {\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nI keep getting a NullReferenceException on the line that calls `finder.GetNupkgStreamAsync` with the following stack trace:\r\n\r\n```csharp\r\n   at NuGet.Protocol.Core.v3.RemoteRepositories.RemoteV3FindPackageByIdResource.<OpenNupkgStreamAsyncCore>d__22.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at NuGet.Protocol.Core.v3.RemoteRepositories.RemoteV3FindPackageByIdResource.<OpenNupkgStreamAsync>d__21.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at NuGet.Protocol.Core.v3.RemoteRepositories.RemoteV3FindPackageByIdResource.<GetNupkgStreamAsync>d__17.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at nuget_core_null_ref.Program.<GetPackageSizeAsync>d__2.MoveNext() in Program.cs:line 42\r\n```"}}