Cannot Access a Disposed Object: IServiceProvider
I've the same problem of #2471
I'm using isolated-function and initially this local.settings.config works. But when we continue relaunching the application for debugging we receive the error Cannot Access a Disposed Object: IServiceProvider without reason.
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": true
}
But this config always works without problems.
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": false
}
Here's some dependency versions I'm using:
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
something else...
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.9.0" />
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
something else...
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": true
}
}
Having the exact same issue, very frustrating as it prevents me from receiving credentials in my API function.
Cannot access a disposed object.
Object name: 'IServiceProvider'.
When CORSCredentials is set to true...making is almost impossible for me to develop against an isolated function API
For anyone else hitting this, you need to specify a specific host in the CORS setting to use CORSCredentials. See here for details https://stackoverflow.com/a/77152249
It would be nice if a more legible error message was returned in this case though