question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update Mapster.Tool to include .net6.0 as target framework

See original GitHub issue

I’m using Mapster.Tool to generate mappers from interfaces. When I tried updating my project to .NET 6.0 an exception is thrown.

Updating the target framework in Mapster.Tool to include net6.0 fixes the issue.

The issue can be reproduced with a new console application running .NET 6. Program.cs:

using Mapster;

Console.WriteLine("Hello, World!");

public class A
{
    public string Str { get; set; }
}

public class B
{
    public string Str { get; set; }
}

[Mapper]
public interface IMapper
{
    A Map(B test);
}

public class MyRegister : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        config.NewConfig<A, B>();
    }
}

Running dotnet mapster mapper -a ".\bin\Debug\net6.0\MapsterNet6Issue.dll" outputs the following error

Cannot find assembly path: System.Runtime (type=package, version=5.0.11-servicing.21473.8)
Cannot find assembly path: System.Runtime (type=package, version=5.0.11-servicing.21473.8)
Cannot find assembly path: System.Runtime (type=package, version=5.0.11-servicing.21473.8)
Cannot find assembly path: System.Runtime (type=package, version=5.0.11-servicing.21473.8)
Unhandled exception. System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Mapster.TypeAdapterConfig.<>c.<Scan>b__87_0(Assembly assembly) in D:\git\Mapster\src\Mapster\TypeAdapterConfig.cs:line 619
   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Mapster.TypeAdapterConfig.Scan(Assembly[] assemblies) in D:\git\Mapster\src\Mapster\TypeAdapterConfig.cs:line 619
   at Mapster.Tool.Program.GenerateMappers(MapperOptions opt) in D:\git\Mapster\src\Mapster.Tool\Program.cs:line 65
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at Mapster.Tool.Program.Main(String[] args) in D:\git\Mapster\src\Mapster.Tool\Program.cs:line 17
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
janiskuljcommented, Apr 11, 2023

Any chance to add .net7.0 target framework?

1reaction
vladmldcommented, Feb 21, 2022

Please try the latest version now available on NuGet and let me know how it goes. I’m on standby to resolve any issues you may encounter.

Seems to be working so far, had to remember to run dotnet tool update Mapster.Tool. Cheers!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Releases · MapsterMapper/Mapster
This release finally resolves the long awaited support for .NET 6.0 in Mapster and Mapster.Tool! Fresh packages can be downloaded from ...
Read more >
Mapster.Tool 8.3.0
Tool to generate object mapping using Mapster.
Read more >
Mapster.Tool fails generating mapper
Mapster.Tool fails to generate any code. The problem seems to be a class derived from CosmosClient - which i get from a nuget...
Read more >
Getting Started With Mapster in ASP.NET Core
Mapster is an object-to-object mapper used in .NET projects. Let's learn what it can do and how it compares to the giants like...
Read more >
Mapster
Updating the target framework in Mapster.Tool to include net6.0 fixes the issue. The issue can be reproduced with a new console application running...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found