How to fix Common Language Runtime detected an invalid program.

Rajendra Mote 0 Reputation points
2023-07-26T12:32:31.4733333+00:00

The project has .net framework 4.8 and automapper 7.0.1 package. Error information is as below,

================================================================================ exception

Type : InvalidProgramException
Message : Common Language Runtime detected an invalid program.
Source : mscorlib

Stack Trace:
at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method)
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
at AutoMapper.MapperConfiguration.CreateMapperFuncs(MapRequest mapRequest) in C:\projects\automapper\src\AutoMapper\MapperConfiguration.cs:line 110
at AutoMapper.LockingConcurrentDictionary2.<>c__DisplayClass2_1.<.ctor>b__1() in C:\projects\automapper\src\AutoMapper\LockingConcurrentDictionary.cs:line 15 at System.Lazy1.CreateValue()
at System.Lazy`1.LazyInitValue()
at AutoMapper.MapperConfiguration.GetUntypedMapperFunc(MapRequest mapRequest) in C:\projects\automapper\src\AutoMapper\MapperConfiguration.cs:line 108
at AutoMapper.Mapper.AutoMapper.IMapper.MapTDestination in C:\projects\automapper\src\AutoMapper\Mapper.cs:line 207

 

code line throwing error :- Service.method( Mapper.Map<class name>(obj));

Developer technologies .NET Other
Developer technologies ASP.NET Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.