question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Object reference not set.... .net 6 functions

See original GitHub issue

Describe the issue When using this library in a new Azure Functions project (.net6, runtime V4) it works locally but not on Azure.

Object reference not set to an instance of an object.

To Reproduce

  1. Create new Azure functions project with .Net 6
  2. Add a new project without dependencies and reference it in your functions project
  3. Deploy to Azure
  4. Call /api/swagger.json

Expected behavior I expect that swagger would just work like it does locally.

Screenshots

image

Environment (please complete the following information, if applicable):

  • OS: Azure (Windows Service plan, FUNCTIONS_EXTENSION_VERSION = ~4, FUNCTIONS_WORKER_RUNTIME = dotnet)
  • Version 1.0.0 (nuget)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
chris-parker-blisscommented, Mar 30, 2022

Hi @justinyoo - I can confirm that even after updating to v1.3.0 of the Microsoft.Azure.WebJobs.Extensions.OpenApi package I’m still seeing the following error when my function app references a net6.0 class library which has no dependencies:

Object reference not set to an instance of an object.

   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.<>c.<GetRuntimeFilenameAsync>b__43_1(KeyValuePair`2 target)
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.Contains[TSource](IEnumerable`1 source, TSource value, IEqualityComparer`1 comparer)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.<>c__DisplayClass43_0.<GetRuntimeFilenameAsync>b__3(<>f__AnonymousType0`3 r)
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.GetRuntimeFilenameAsync(String functionAppDirectory)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.SetApplicationAssemblyAsync(String functionAppDirectory, Boolean appendBin)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions.OpenApiHttpTriggerContextExtensions.AuthorizeAsync(Task`1 context, IHttpRequestDataObject req)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiTriggerFunctionProvider.RenderSwaggerUI(HttpRequest req, ExecutionContext ctx, ILogger log)
3reactions
PedroLucasSilvacommented, Feb 7, 2022

I had the same problem and I solved it based on an old issue. Where the person indicated that all projects on their system must have at least one dependency. I added a random package to a project of mine that didn’t have any and it started working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - .net 6 - Object reference not set to an instance of an ...
The Populate function takes in a List of strings, which are comma separated. There is an array of integers passed in, which will...
Read more >
`Object reference not set to an instance of an ...
Function running the queue trigger after passing message to the queue and getting exception while sending it to the Azure Table within the...
Read more >
Fixing the "The following functions are in error: Object ...
Fixing the “The following functions are in error: Object reference not set to an instance of an object.” error in Azure Functions.
Read more >
Object Reference Not Set to an Instance of an Object
This infamous and dreaded error message happens when you get a NullReferenceException. This exception is thrown when you try to access a member—for...
Read more >
Fix “Object Reference Not Set to an Instance of an ... - YouTube
Fix “ Object Reference Not Set to an Instance of an Object” in Microsoft Visual Studio In this post, we will show you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found