Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kshyju opened this issue Aug 20, 2024 · 0 comments · Fixed by #10411
Assignees
Labels

Comments

@kshyju
Copy link
Member

kshyju commented Aug 20, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants