MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.29k stars 327 forks source link

Mapster.TypeAdapterConfig #556

Open rajibrezwan opened 1 year ago

rajibrezwan commented 1 year ago

I am receiving this error " The type initializer for 'Mapster.TypeAdapterConfig' threw an exception " on mapster 7.2.0 , couldnt use theupdated version cause it breakes my azure msbuild , is there a solution for this ?

andrerav commented 1 year ago

Please add more information.

rajibrezwan commented 1 year ago

I am using it for Asp.net legacy application this is how i am using it .Once it finishes running the method I get the exception . My Application doesnt have .net core so I wont be able to use DI as the documentation suggested.I am pretty new with this so please bear with me@andrerav

using System;
using Mapster;

namespace VirtualPremise.Domain.Financials.BLL
{
    [Serializable()]
    public class GLGroupEvent : GLEventInfo
    {
        public int GLEventGroupID { get; set; }

        public string GroupName { get; set; }

        public decimal ChangeInIndex { get; set; }

        public static GLGroupEvent GetGLGroupEvent(int glEventID, string sitekey)
        {
            try
            {
                GLEventInfo eventInfo;
                eventInfo = BLL.GLEventInfo.GetGLEvent(glEventID, sitekey);
                var grpEvent = eventInfo.Adapt<GLGroupEvent>();
                return grpEvent;
            }
            catch (Exception ex)
            {

                throw;
            }

        }