Версия VsCode: 1.89.0
ОС: Windows 10
Версия Dotnet: .Net 8
Языковая версия C#: 12
Код, вызывающий исключение
Код: Выделить всё
Type[] types = [
.. Assembly.GetAssembly(typeof(Application.DependencyInjection))!
.GetTypes(),
.. Assembly.GetAssembly(typeof(Infrastructure.DependencyInjection))!
.GetTypes()
];
Код: Выделить всё
Exception has occurred: CLR/System.ArrayTypeMismatchException
Exception thrown: 'System.ArrayTypeMismatchException' in System.Private.CoreLib.dll: 'Attempted to access an element as a type incompatible with the array.'
at System.ThrowHelper.ThrowArrayTypeMismatchException()
at System.Span`1..ctor(T[] array)
at Webmonitor.Infrastructure.Data.Dapper.DapperMappingRegistration.RegisterDapperMappers() in C:\Mahbubur\Projects\WM 4\NextGenAPI\Webmonitor.Infrastructure\Data\Dapper\DapperMappingRegistration.cs:line 21
Код: Выделить всё
public static void RegisterDapperMappers()
{
Type[] types = [
.. Assembly.GetAssembly(typeof(Application.DependencyInjection))!
.GetTypes(),
.. Assembly.GetAssembly(typeof(Infrastructure.DependencyInjection))!
.GetTypes()
];
var typesWithColumnAttributes = types
.Where(t => t.GetProperties().Any(p => p.GetCustomAttribute() is not null))
.Where(t => !t.IsInterface && !t.IsAbstract);
foreach (var type in typesWithColumnAttributes)
{
SqlMapper.SetTypeMap(type, new DapperCustomAtrributeMapper(type));
}
}
Код: Выделить всё
Type[] types = Assembly
.GetAssembly(typeof(Webmonitor.Application.DependencyInjection))!
.GetTypes()
.Concat(Assembly.GetAssembly(typeof(Webmonitor.Infrastructure.DependencyInjection))!.GetTypes())
.ToArray();
Подробнее здесь: https://stackoverflow.com/questions/784 ... on-8-0-204