Skip to content

Microsoft.AspNetCore.OpenApi throwing System.NullReferenceException: 'Object reference not set to an instance of an object.' in .NET 10 #64321

@LightBulbIdea

Description

@LightBulbIdea

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am getting an "Object reference not set to an instance of an object" error in https://github.com/dotnet/dotnet/blob/1c23bbd05201330c302a0a8c7b55b4368df573e6/src/aspnetcore/src/OpenApi/gen/XmlCommentGenerator.Emitter.cs#L447 due to my route having a parameter that is NOT being used in the controller. This worked fine in previous .NET verisons.

ERROR:

Image

Controller that breaks it (all my controllers are designed like this, so pretty much none of my controllers work)

Image

This is what I see when debugging.

Image

Any idea on how to avoid this exception? It is preventing me from moving forward with NET 10.

Expected Behavior

To not throw an exception. It breaks the API.

Steps To Reproduce

Exceptions (if any)

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Image

.NET Version

10

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions