Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException: Method not found #77

Open
adeel41 opened this issue Dec 20, 2018 · 0 comments
Open

MissingMethodException: Method not found #77

adeel41 opened this issue Dec 20, 2018 · 0 comments

Comments

@adeel41
Copy link

adeel41 commented Dec 20, 2018

The following code throws an exception MissingMethodException

using System;
using Nelibur.ObjectMapper;

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            var location = new Location("A", "C:\\", Guid.NewGuid());
            TinyMapper.Bind<Location, LocationDto.Standard>();
            var dto = TinyMapper.Map<LocationDto.Standard>(location);
            Console.WriteLine("Hello World!");
        }
    }

    public class Location
    {
        public Guid Id { get; private set; }
        public string Name { get; private set; }
        public string Path { get; private set; }
        public Guid CreatedByUserId { get; private set; }
        public DateTime CreationDateTime { get; private set; }

        public Location(string name, string path, Guid createdByUserId)
        {
            Id = Guid.NewGuid();
            Name = name;
            Path = path;
            CreatedByUserId = createdByUserId;
            CreationDateTime = DateTime.UtcNow;
        }
    }

    public class LocationDto
    {
        public class New
        {
            public string Name { get; set; }
            public string Path { get; set; }
        }

        public class Standard : New
        {
            public Guid Id { get; set; }
            public Guid CreatedByUserId { get; set; }
            public DateTime CreationDateTime { get; set; }

            public Standard()
            {

            }
        }
    }
}

Exception Deails:

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Nelibur.ObjectMapper.TinyMapper' threw an exception.
Source=TinyMapper
StackTrace:
at Nelibur.ObjectMapper.TinyMapper.BindTSource,TTarget
at ConsoleApp9.Program.Main(String[] args) in C:\Users\amahmood\source\repos\ConsoleApp9\Program.cs:line 11

Inner Exception 1:
TypeInitializationException: The type initializer for 'Nelibur.ObjectMapper.Reflection.DynamicAssemblyBuilder' threw an exception.

Inner Exception 2:
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.

CSPROJ Content

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="TinyMapper" Version="2.0.8" />
  </ItemGroup>

</Project>

BTW, I initially thought that it failed because it needs a default constructor on the target type but it still failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant