Skip to content

Dependency injection fails for oop-host when using a .NET Isolated payload with the worker.sdk package version 1.3.0 or earlier. #10410

@kshyju

Description

@kshyju

When using a .NET Isolated payload with Microsoft.Azure.Functions.Worker.sdk version 1.3.0 or below, host will fail with the following exception.

System.InvalidOperationException: 'Unable to resolve service for type 'System.String' while attempting to activate 'Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader.JsonFunctionProvider'.'

Stack trace

at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain, Int32 slot)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateEnumerable(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceIdentifier serviceIdentifier, CallSiteChain callSiteChain)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.GetService(Type serviceType) in D:\src\azure-functions-host\src\WebJobs.Script.WebHost\WebJobsScriptHostService.cs:line 962

  • The issue does not happen for version 1.5.0-preview1 or above.
  • Issue happens only on dev branch which uses .NET DI framework.
  • No issues with in-proc branch which uses DryIOC.

JsonFunctionProvider constructor was changed between the working and non-working version.

1.30.0

image

1.5.0-preview1

image

We believe DryIOC handles this by passing null/empty string value while .NET DI framework fails. We need to fix the oop host branch to handle this service resolution.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions