henkmollema / Dapper-FluentMap

Provides a simple API to fluently map POCO properties to database columns when using Dapper.
MIT License
429 stars 88 forks source link

FluentMap File Load Exception with Dapper 1.50.7 #83

Closed jmalczak closed 5 years ago

jmalczak commented 5 years ago

Hi. Following test app throws file load exception on .net core 2.2

using Dapper.FluentMap;
using Dapper.FluentMap.Mapping;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            FluentMapper.Initialize(c =>
            {
                c.AddMap(new TestMap());
            });
        }
    }

    public class Test
    {
        public string TestField { get; set; }
    }

    public class TestMap : EntityMap<Test>
    {
        public TestMap()
        {
            Map(p => p.TestField).ToColumn("Test");
        }
    }
}

With following package references

  <ItemGroup>
    <PackageReference Include="Dapper" Version="1.50.7" />
    <PackageReference Include="Dapper.FluentMap" Version="1.7.0" />
  </ItemGroup>
henkmollema commented 5 years ago

Can you provide a stack trace?

jmalczak commented 5 years ago

Hi

Sorry for the late reply. Here are exception details including stack trace:

System.IO.FileLoadException
  HResult=0x80131040
  Message=Could not load file or assembly 'Dapper, Version=1.50.5.0, Culture=neutral, PublicKeyToken=null'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=Dapper.FluentMap
  StackTrace:
   at Dapper.FluentMap.FluentMapper.AddTypeMap[TEntity]()
   at ConsoleApp1.Program.<>c.<Main>b__0_0(FluentMapConfiguration c) in C:\Users\malczu\source\repos\ConsoleApp1\Program.cs:line 12
   at ConsoleApp1.Program.Main(String[] args) in C:\Users\malczu\source\repos\ConsoleApp1\Program.cs:line 10
henkmollema commented 5 years ago

Is there a reason you explicitly need v1.50.7? What happens if you remove <PackageReference Include="Dapper" Version="1.50.7" /> from the project file.

jmalczak commented 5 years ago

No I don't need it to be honest. When I either remove dapper as separate dependency and use only transitive dependency via FluentMap. Or keep it as separate dependency and downgrade to 1.50.5 it works fine. But I saw requirement Dapper (>= 1.50.5) during nuget install which is kind of correct for 1.50.7.

Thanks

henkmollema commented 5 years ago

Thanks for the investigation. Obviously it should just work. I'll try to get a repro on my machine.

jmalczak commented 5 years ago

No problem, thanks for the library. If you will figure out what is wrong, that it doesn't work by default, please put a note here.

Thanks again!

maoxian-1 commented 5 years ago

I also encountered the same problem on .net framework 4.5.2

jarrettv commented 5 years ago

Dapper fixed this problem in the latest 1.60.1 version

SIkebe commented 5 years ago

Dapper fixed this problem in the latest 1.60.1 version

I've confirmed this issue fixed with Dapper v1.60.1, too.

henkmollema commented 5 years ago

Dapper.FluentMap v1.8 is release with the updated Dapper package.