'Handled exception causes an AccessViolationException

I would like to ask for help with a C# API Project, to be more specific, an exception that have been giving issues for some pretty long time now. Currently the projects runs on .NET Core 3.1 and it uses Hangfire.

Basically, the problem is that back when we used Visual Studio 2019, whenever we had any handled exception the application would keep running just fine, however once we updated to Visual Studio 2022, any throw exception in development environment will make the application stop giving us usually two exceptions. Lets suppose a NullReferenceException has happened, right after it the application would keep running, however we get a System.AccessViolationException:

System.AccessViolationException

That's the issue, the AccessViolationException will make the application stop despite the exception that caused it (NullReferenceException for example) be a handled exception.

Enabling native code debugging doesn't help much since it will just mention that the exception thrown will be at the KernelBase.dll.

I read somewhere that enabling Microsoft Symbols Servers in Options->Debugging->Symbols may give more details into this exception, but enabling it either makes the application not start or makes it starts way too slowly.

This doesn't happen with some of our other projects. Not sure if it has anything to do with it, but that other project doesn't use Hangfire and runs in .NET Core 3.1. Weirdly, other computers that runs the same project, on the same OS, on VS2022 doesn't have such issue.

So far we've tried to reinstall the .NET Core Sdks, reinstall VS2022, installing the same Sdk that the working computers have and even downgrading to VS2019 (where it used to work). None of them have worked. Did anyone went through this or had something similar?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source