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

  • Home
  • SEARCH
  • 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 8728671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:41:37+00:00 2026-06-13T08:41:37+00:00

I am using Automapper in my project to map business entities to DTO. public

  • 0

I am using Automapper in my project to map business entities to DTO.

public class TransportStop
{
    public Point[] Points { get; set; }
}

public class TransportStopDto
{
    public PointDto[] Points { get; set; }

    public TransportStopDto()
    {
        Points = new PointDto[0];
    }
}

In constructor I am initializing Points property with an empty array to make sure it is always not null. I am using basic configuration for mapping.

Mapper.CreateMap<Point, PointDto>();
Mapper.CreateMap<TransportStop, TransportStopDto>();

TransportStop stop = new TransportStop()
{
    Points = new Point[]
    {
        new Point() { X = 1, Y = 1 },
        new Point() { X = 2, Y = 2 }
    }
};

TransportStopDto dto = Mapper.Map<TransportStop, TransportStopDto>(stop);

With Automapper 2.0.0 it worked just fine, but after upgrading to version 2.2.0 I get mapping exception with inner exception:

Index was outside the bounds of the array

It seems Automapper tries to map every member of array, instead of overwriting the whole array. If I remove property initialization from constructor and leave it null, everything works.

Is it possible to configure Automapper 2.2.0 to always overwrite existing array property with new one?

  • 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-06-13T08:41:38+00:00Added an answer on June 13, 2026 at 8:41 am

    I solved my problem by downgrading to version 2.0.0.

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

Sidebar

Related Questions

I am using AutoMapper + EF (Entities => POCO) for the following class: public
I am using automapper (successfully up to a point) to perform a polymorphic map
In a project using NHibernate, I have this class : public class AdminVAT :
In my ASP.NET MVC 2 (RC) project - I'm using AutoMapper to map between
I'm using EF 4.1 and code-first in an MVC project, and AutoMapper to map
I am using AutoMapper.org to map my DTO objects to Model objects in MVC4.
I have this interface for using AutoMapper: public interface IMapper { object Map(object source,
I've just finished setting up a project using MVC 3, Fluent nHibernate, AutoMapper, and
I am using AutoMapper in my project along with, NHibernate and ASP.NET MVC 2.
I am using Automapper to map between Entity and ViewModel object (in both directions).

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.