Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:09:43+00:00 2026-05-23T07:09:43+00:00

A strange error began occurring in our code in the lest week or two.

  • 0

A strange error began occurring in our code in the lest week or two. I am trying to identify the root cause of the mapping failure. The most-inner exception itself is puzzling: Type 'System.String' does not have a default constructor

I don’t understand what the exception is telling me. Can you explain what has happened and maybe how I could resolve this bug?

The mapper is used within a generic method:

public TEntity UpdateWithHistory<TEntity>(TEntity entity, int? entityID, int? interviewID)
where TEntity : class
{
    var snapshot = _interviewContext.Find<TEntity>(entityID);

    // This is call that fails
    var history = Mapper.Map<TEntity, TEntity>(snapshot);

    _interviewHistory.Set<TEntity>().Add(history);
    MarkModified(entity);
    return Mapper.Map(entity, snapshot);
}

In the above code, snapshot is NOT null. The full exception:

AutoMapper.AutoMapperMappingException:
Trying to map Recog.Web.Models.InterviewComment to Recog.Web.Models.InterviewComment.
Using mapping configuration for Recog.Web.Models.InterviewComment to Recog.Web.Models.InterviewComment
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
  ---> AutoMapper.AutoMapperMappingException: Trying to map System.String to System.String.
       Using mapping configuration for System.String to System.String
       Destination property: Comment
       Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
  ---> AutoMapper.AutoMapperMappingException: Trying to map System.String to System.String.
       Using mapping configuration for System.String to System.String
       Destination property: Comment
       Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
  ---> System.ArgumentException: Type 'System.String' does not have a default constructor
     at System.Linq.Expressions.Expression.New(Type type)
     at AutoMapper.DelegateFactory.CreateCtor(Type type)
     at AutoMapper.Mappers.ObjectCreator.CreateObject(Type type)
     at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.CreateObject(ResolutionContext context)
     at AutoMapper.Mappers.TypeMapObjectMapperRegistry.NewObjectPropertyMapMappingStrategy.GetMappedObject(ResolutionContext context, IMappingEngineRunner mapper)
     at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.Map(ResolutionContext context, IMappingEngineRunner mapper)
     at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context, IMappingEngineRunner mapper)
     at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
     --- End of inner exception stack trace ---
     at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
     at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.MapPropertyValue(ResolutionContext context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap propertyMap)
     --- End

The Comment class that is mentioned:

public class InterviewComment
{
    [Key]
    public int? InterviewCommentID { get; set; }

    [ForeignKey("Interview")]
    public int? InterviewID { get; set; }

    [CodeType(CodeTypeEnum.CommentSection)]
    public int? CommentSectionCodeID { get; set; }

    [CodeType(CodeTypeEnum.CommentSource)]
    public int? CommentSourceCodeID { get; set; }

    [Display(Name = "Comment")]
    [StringLength(int.MaxValue)]
    public string Comment { get; set; }

    [Include]
    [Association("Interview_1-*_InterviewComment", "InterviewID", "InterviewID", IsForeignKey = true)]
    public virtual Interview Interview { get; set; }

    [ReadOnly(true)]
    [ForeignKey("ModifiedByUser")]
    public virtual ApplicationUser ApplicationUser { get; set; }

    [ReadOnly(true)]
    public string UserName
    {
        get { return ApplicationUser != null ? ApplicationUser.GetDisplayName() : null; }
    }

    [ReadOnly(true)]
    public int CreatedByUser { get; set; }

    [ReadOnly(true)]
    public DateTime CreatedDateTime { get; set; }

    [ReadOnly(true)]
    public int ModifiedByUser { get; set; }

    [ReadOnly(true)]
    public DateTime ModifiedDateTime { get; set; }
}

I’m still reviewing recent commits to identify the change that is causing this. Any insight into the exception would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:09:43+00:00Added an answer on May 23, 2026 at 7:09 am

    The root cause of the error was in code that was not shared. We have a convention that configured mappings for specific types discovered through reflection. Our algorithm incorrectly created a map for string, replacing the default mapping provided by AutoMapper.

    Should you ever see the error Type 'System.String' does not have a default constructor, confirm your code does not create a map for string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The story began with a very strange error while I was running my script
I am getting a strange error after trying to compile under 2010. The compiler
We got strange error last days. ___doPostBack is undefined. We are building quite advanced
I seem to be getting a strange error when I run my tests in
I have an application where every now and then I'm getting a strange error.
I'm seeing strange errors when my C++ code has min() or max() calls. I'm
Here's a strange one. After renaming a class, one of my forms began giving
Strange error i received from compiler: Expected a child component type of UISelectItem/UISelectItems for
Today, I encounter a strange problem. My c++ code can work under debug mode.
I've got a strange error with IE8 and postcode lookups. It may not be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.