Azure / Azure/azure-functions-dotnet-extensions

Cryptic error messages when using FunctionsStartup DI if DI fails.

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
81
Forks
50
PR merge metrics
No merged PRs in 30d

Description

When there is an error with the DI setup I am getting a verry cryptic error message that is not really helping to find the cause of actual issue. (local development)

` Anonymously Hosted DynamicMethods Assembly: Object reference not set to an instance of an object.`
If I wrap repro code in a custom serviceprovider I i can see the actual issue:
`Microsoft.Extensions.DependencyInjection: Unable to resolve service for type 'System.Int32' while attempting to activate 'FunctionApp2Injection2.Test'.` Now of course in the attached example its trivial to see what goes wrong, but for a somewhat larger dependency tree its hard to find the root cause with such a cryptic error message. Unless the actual error is stored somewhere I am unable to find...

Attached is an example showing both situations.
[FunctionApp2Injection2.zip](https://github.com/Azure/azure-functions-dotnet-extensions/files/3260460/FunctionApp2Injection2.zip)
It can be run locally to get the errors.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the attached FunctionApp2Injection2.zip and run the example locally to reproduce the cryptic FunctionsStartup DI failure. Compare it with the custom service-provider output, then ensure DI setup failures expose the underlying dependency-resolution cause rather than only the dynamic-methods null-reference message.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.