0

My application is getting an AutoMapper.AutoMapperMappingException that the object is not set to an instance of an object. I see in the mapping.cs file that it is being created so I am not sure where why I am getting this error.

TypeConverter.CS

Mapper.DynamicMap(value, cycleActionDefinition, value.GetType(),
                            typeof(PlanDefinition.ActionComponent));

Mappings.cs

Mapper.CreateMap<TreatmentSettingsSentencePartModel, PlanDefinition.ActionComponent>()
                .ConvertUsing<IndicationsToActionDefinitionTypeConverter>();

Full StackTrace

<StackTrace>
at OrderTemplateTool.Web.Common.TemplateExportManager.ExportInternal(Template template, Format format) in C:\WebProjects\COTT\COTT\OrderTemplateTool.Web\Common\TemplateExportManager.cs:line 94 at OrderTemplateTool.Web.Common.TemplateExportManager.ExportAndSave(Template template, Format format) in C:\WebProjects\COTT\COTT\OrderTemplateTool.Web\Common\TemplateExportManager.cs:line 116 at OrderTemplateTool.Web.Controllers.Api.FhirController.Read(String type, String id) in C:\WebProjects\COTT\COTT\OrderTemplateTool.Web\Controllers\Api\FhirController.cs:line 126 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
</StackTrace>
Trevor
  • 7,777
  • 6
  • 31
  • 50
Jefferson
  • 173
  • 2
  • 12
  • 32
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Trevor Jul 18 '19 at 15:23
  • Also `TemplateExportManager.cs` seems to be the culprit of the error, how come you don't show us this class? – Trevor Jul 18 '19 at 15:25
  • TemplateExportManager.cs is just the class calling the function. – Jefferson Jul 18 '19 at 15:29

0 Answers0