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 1046019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:04:39+00:00 2026-05-16T16:04:39+00:00

I am getting the following exception when calling any of my Mapper.Map methods. Inheritance

  • 0

I am getting the following exception when calling any of my Mapper.Map methods.

Inheritance security rules violated while overriding member: ‘Castle.Core.Logging.LevelFilteredLogger.InitializeLifetimeService()’.
Security accessibility of the overriding method must match the
security accessibility of the method being overriden.

I am using the latest build of AutoMapper downloaded from codeplex inside my S#arp 1.6 application running on .Net 4.0 (which is using version 1.2.0.6623 of Castle.Core).

I beleive it has something to do with the new .Net 4.0 security settings which I don’t quite understand.

Is there a way to fix it?

Paul

  • 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-16T16:04:39+00:00Added an answer on May 16, 2026 at 4:04 pm

    I tried something from a little googling which fixed my problem, i’m not sure if this is the ideal or recommended approach but it worked.

    I added this to the Automapper projects ‘AssemblyInfo.cs’ file:

    [assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
    

    I recompiled and used the new DLL and everything worked fine.

    Please leave comments if this isn’t reccomended or if there is a better approach.

    For now though i will leave my own answer as the correct one.

    Thanks for the help though!

    UPDATE:

    My mappings are pretty simple, sorry about all the code but thought it may help you:

    Initialisation Code:

    Mapper.Reset();
    Mapper.Initialize(x =>
    {
        x.AddProfile<LeadsProfile>();
        //x.AddProfile<AttendeeProfile>();
    });
    
    Mapper.AssertConfigurationIsValid();
    

    LeadsProfile.cs

    public class LeadsProfile : AutoMapper.Profile
            {
                public override string ProfileName
                {
                    get { return "LeadsProfile"; }
                }
    
                protected override void Configure()
                {
    
                    Mapper.CreateMap<Lead, LeadDto>();
    
                    Mapper.CreateMap<Lead, LeadDetailDto>();
    
                    Lead lead = null;
                    Mapper.CreateMap<int, LeadDetailDto>()
                        .BeforeMap((s, d) => lead = ServiceLocator.Current.GetInstance<ILeadRepository>().FindOne(s))
                        .ForMember(d => d.Id, x => x.MapFrom(s => lead.Id))
                        .ForMember(d => d.Fullname, x => x.MapFrom(s => lead.Fullname))
                        .ForMember(d => d.TelNumber, x => x.MapFrom(s => lead.TelNumber))
                        .ForMember(d => d.BookedAppointmentDate, x => x.MapFrom(s => lead.BookedAppointmentDate));
    
                }
    
            }
    

    Source Class

    public class Lead : Entity
        {
            public Lead()
            {
                Status = Common.LeadStatus.Raw;
                CreatedDate = DateTime.Now;
            }
    
            public Lead(Branch branch, Promoter promoter, LeadSource source, string fullname, string telNumber, Address address, DateTime apptDate) : this()
            {
                this.Branch = branch;
                this.Promoter = promoter;
                this.Source = source;
                this.Fullname = fullname;
                this.TelNumber = telNumber;
                this.Address = address;
                this.BookedAppointmentDate = apptDate;
            }
    
            public virtual Branch Branch { get; set; }
            public virtual Promoter Promoter { get; set; }
            public virtual LeadSource Source { get; set; }
            public virtual Common.LeadStatus Status { get; set; }
    
            public virtual bool ExistingCustomer { get; set; }
            public virtual bool IsDoso { get; set; }
    
            public virtual string TitlePrefix { get; set; }
            public virtual string Fullname { get; set; }
            public virtual string TelNumber { get; set; }
            public virtual string MobileNumber { get; set; }
    
            public virtual DateTime BookedAppointmentDate { get; set; }
    
            public virtual Address Address { get; set; }
    
            public virtual Store Store { get; set; }
    
            public virtual IList<LeadProduct> Products { get; set; }
            public virtual IList<Appointment> Appointments { get; set; }
            public virtual IList<Sale> Sales { get; set; }
    
            public virtual DateTime CreatedDate { get; set; }
        }
    

    Destination Dto’s

    public class LeadDto
        {
            public int Id { get; set; }
            public string Fullname { get; set; }
            public string TelNumber { get; set; }
            public DateTime BookedAppointmentDate { get; set; }
        }
    
    public class LeadDetailDto
        {
            public int Id { get; set; }
            public string Fullname { get; set; }
            public string TelNumber { get; set; }
            public DateTime BookedAppointmentDate { get; set; }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the following thrown error when calling a web service. Have googled without any
I am getting following Exception on Android 2.2.1: java.lang.NoSuchMethodError: java.lang.String.isEmpty I am calling text.isEmpty
I'm getting the following exception when calling 'GetProjectItemSummariesQuery' against my RIA Service. The weird
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
I'm getting this Exception System.InvalidOperationException was unhandled by user code Message=The calling thread cannot
Why does the following code throw an exception when getting to the second scanf_s
I am getting the following exception. There are two records in the table and
I've been getting the following exception when trying to send an e-mail using System.Net.Mail:
I'm getting the following error in my WCF project: An unhandled exception of type
I'm getting the following (intermittent) errors in my workflow tracking: An error occurred while

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.