{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/139","repository_url":"https://api.github.com/repos/IdentityModel/IdentityModel2","labels_url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/139/comments","events_url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/139/events","html_url":"https://github.com/IdentityModel/IdentityModel2/issues/139","id":349148212,"node_id":"MDU6SXNzdWUzNDkxNDgyMTI=","number":139,"title":"Method not found: 'Void IdentityModel.Client.TokenClient..ctor(System.String, System.String, System.String, System.Net.Http.HttpMessageHandler, IdentityModel.Client.AuthenticationStyle)'.","user":{"login":"chazt3n","id":3843179,"node_id":"MDQ6VXNlcjM4NDMxNzk=","avatar_url":"https://avatars0.githubusercontent.com/u/3843179?v=4","gravatar_id":"","url":"https://api.github.com/users/chazt3n","html_url":"https://github.com/chazt3n","followers_url":"https://api.github.com/users/chazt3n/followers","following_url":"https://api.github.com/users/chazt3n/following{/other_user}","gists_url":"https://api.github.com/users/chazt3n/gists{/gist_id}","starred_url":"https://api.github.com/users/chazt3n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chazt3n/subscriptions","organizations_url":"https://api.github.com/users/chazt3n/orgs","repos_url":"https://api.github.com/users/chazt3n/repos","events_url":"https://api.github.com/users/chazt3n/events{/privacy}","received_events_url":"https://api.github.com/users/chazt3n/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-09T14:17:41Z","updated_at":"2018-08-10T14:03:23Z","closed_at":"2018-08-10T14:03:23Z","author_association":"NONE","body":"Good morning, I've got a netstandard nuget package that was created within a .NET Core 2.1 app and is being referenced in a .NET 4.6.1 application.\r\n\r\nThe .NET framework app is hosted on Local IIS and it works perfectly until I rebuild the project. When I do this I see the above message and I have to perform an IISReset in order for it to work again.\r\n\r\nI've ensured that all the .NET framework projects in the SLN do not use the system.net.http 4.3.3 nuget package and the csproj's all explicitly reference 4.2.0.0. \r\n\r\nIt feels like something isn't letting go of the HttpMessageHandler\r\n\r\nBelow is the code that I felt best to share but if there's anything at all I can provide to help resolve this please let me know, thank you so much for your time and amazing product\r\n\r\nThe TokenClient built in the .NET Core app as a netstandard application\r\n```\r\n        public async Task<string> GetTokenAsync()\r\n        {\r\n            try\r\n            {\r\n                string accessToken = await _cache.GetStringAsync(_tokenCacheKey).ConfigureAwait(false);\r\n                HttpContext context = _httpContextAccessor.HttpContext;\r\n                if (accessToken == null)\r\n                {\r\n                    var tokenClient = new TokenClient(_identityServerTokenUrl, _applicationName, _clientSecret);\r\n                    TokenResponse tokenResponse = await tokenClient.RequestClientCredentialsAsync(ApiResourceName).ConfigureAwait(false);\r\n                    if (tokenResponse.IsError)\r\n                    {\r\n                        throw new Exception($\"Error communicating with token endpoint: {tokenResponse.ToJson()}\");\r\n                    }\r\n\r\n                    accessToken = tokenResponse.AccessToken;\r\n                    if (string.IsNullOrEmpty(accessToken))\r\n                    {\r\n                        var errorMessage = $\"Access token null for application: {_applicationName}\";\r\n                        throw new Exception(errorMessage);\r\n                    }\r\n\r\n                    string cacheDuration = _config[IdentityServerCacheDurationConfig]\r\n                                           ?? DefaultIdentityServerCacheDuration;\r\n                    await _cache.SetStringAsync(_tokenCacheKey, accessToken, new DistributedCacheEntryOptions()\r\n                    {\r\n                        AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(Convert.ToDouble(cacheDuration))\r\n                    }).ConfigureAwait(false);\r\n                }\r\n\r\n                return accessToken;\r\n            }\r\n            catch (Exception exception)\r\n            {\r\n                _logger.LogError(exception, exception.Message);\r\n                throw;\r\n            }\r\n        }\r\n```\r\n\r\nThese are registered in the .NET Framework App using Autofac like so:\r\nEDIT: I've changed the lifetime of each of these dependencies to singletons, to all be created each request, etc etc. The most bizarre thing is the app works flawlessly until the code is rebuilt\r\n \r\n```\r\n            builder.RegisterType<ClientTokenService>()\r\n                .As<IClientTokenService>()\r\n                .InstancePerLifetimeScope();\r\n\r\n            builder.RegisterType<Client>()\r\n                .As<IClient>()\r\n                .InstancePerLifetimeScope();\r\n\r\n            builder.Register(ctx => new LoggerFactory().CreateLogger<Client>()).SingleInstance();\r\n            builder.Register(ctx => new LoggerFactory().CreateLogger<ClientTokenService>()).SingleInstance();\r\n            builder.Register<IConfiguration>(ctx =>\r\n            {\r\n                IEnumerable<KeyValuePair<string, string>> appSettings = new List<KeyValuePair<string, string>>()\r\n                {\r\n                    new KeyValuePair<string, string>(\"IdentityServer:AccessTokenCacheKey\", ConfigurationManager.AppSettings.Get(\"AccessTokenCacheKey\")),\r\n                    new KeyValuePair<string, string>(\"ApplicationName\", ConfigurationManager.AppSettings.Get(\"ApplicationName\")),\r\n                    new KeyValuePair<string, string>(\"IdentityServer:Authority\", ConfigurationManager.AppSettings.Get(\"IdentityServer.Url\")),\r\n                    new KeyValuePair<string, string>(\"IdentityServer:ClientSecret\", ConfigurationManager.AppSettings.Get(\"IdentityServer.ClientSecret\")),\r\n                    new KeyValuePair<string, string>(\"IdentityServer:CacheDuration\", ConfigurationManager.AppSettings.Get(\"IdentityServer.CacheDuration\")),\r\n                    new KeyValuePair<string, string>(\"Apis:AuthScheme\", ConfigurationManager.AppSettings.Get(\"AuthScheme\")),\r\n                    new KeyValuePair<string, string>(\"Apis:ApiUri\", ConfigurationManager.AppSettings.Get(\"API.Url\"))\r\n                };\r\n                var configBuilder = new ConfigurationBuilder().AddInMemoryCollection(appSettings);\r\n                var configuration = configBuilder.Build();\r\n                return configuration;\r\n            }).SingleInstance();\r\n\r\n            builder.Register<IDistributedCache>(ctx => new MemoryDistributedCache(new OptionsWrapper<MemoryDistributedCacheOptions>(new MemoryDistributedCacheOptions()))).SingleInstance();\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/comments/412092000","html_url":"https://github.com/IdentityModel/IdentityModel2/issues/139#issuecomment-412092000","issue_url":"https://api.github.com/repos/IdentityModel/IdentityModel2/issues/139","id":412092000,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMjA5MjAwMA==","user":{"login":"chazt3n","id":3843179,"node_id":"MDQ6VXNlcjM4NDMxNzk=","avatar_url":"https://avatars0.githubusercontent.com/u/3843179?v=4","gravatar_id":"","url":"https://api.github.com/users/chazt3n","html_url":"https://github.com/chazt3n","followers_url":"https://api.github.com/users/chazt3n/followers","following_url":"https://api.github.com/users/chazt3n/following{/other_user}","gists_url":"https://api.github.com/users/chazt3n/gists{/gist_id}","starred_url":"https://api.github.com/users/chazt3n/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chazt3n/subscriptions","organizations_url":"https://api.github.com/users/chazt3n/orgs","repos_url":"https://api.github.com/users/chazt3n/repos","events_url":"https://api.github.com/users/chazt3n/events{/privacy}","received_events_url":"https://api.github.com/users/chazt3n/received_events","type":"User","site_admin":false},"created_at":"2018-08-10T14:03:23Z","updated_at":"2018-08-10T14:03:23Z","author_association":"NONE","body":"We resolved this by copying this exact code/setup to a new .NET 4.6.1 project and nugetizing that. Everything works as expected now. \r\n\r\nIt seems netstandard + system.net.http + framework is just going to be a problem."}}
{"actor":{"display_login":"chazt3n"}}