'Exception after .net 6 upgrade

The following code (which worked fine in .net core 3.1)

var jobType = AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(x => x.DefinedTypes)
.Single(x => x.FullName == className);

is throwing the exception after the upgrade to .net 6 enter image description here

className is the namespace to a class we need to dynamically instantiate my.redacted.namespace.Jobs.ReminderMail.MonthlyUpdateReminderJob

Is this way of dynamically getting the Type not possible anymore and what would be the way to go?

Thanks in advance



Sources

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

Source: Stack Overflow

Solution Source