Skip to content

Mapster.Tool new FileNotFoundException after latest update #572

@CountingSheep02

Description

@CountingSheep02

Hello @andrerav,

We're having an issue after upgrading from Mapster.Tool 8.4.0-pre05 to 8.4.0-pre06 which incorporated these changes from merge #544. I'm running on macOS and using .NET 7

Our project is structured into a Models library which is then referenced by a Mappings library that contains the IRegister classes and generated code that is output by the Mapster.Tool package.

When running the new prerelease package, we get an error that it can't load all of the assemblies anymore.

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Google.Protobuf, Version=3.22.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'. The system cannot find the file specified.

  File name: 'Google.Protobuf, Version=3.22.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604'
     at SampleApplication.Mappings.SampleRegister.Register(TypeAdapterConfig config)
     at Mapster.TypeAdapterConfig.Apply(IEnumerable`1 registers) in C:\Projects\Mapster\src\Mapster\TypeAdapterConfig.cs:line 662
     at Mapster.TypeAdapterConfig.Scan(Assembly[] assemblies) in C:\Projects\Mapster\src\Mapster\TypeAdapterConfig.cs:line 651
     at Mapster.Tool.Program.GenerateExtensions(ExtensionOptions opt) in C:\Projects\Mapster\src\Mapster.Tool\Program.cs:line 386
     at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
     at Mapster.Tool.Program.Main(String[] args) in C:\Projects\Mapster\src\Mapster.Tool\Program.cs:line 18

I noticed the previously referenced merge(#544 ) removed the AssembyResolver.cs and switched over to using:

Assembly.LoadFrom(Path.GetFullPath(opt.Assembly));

previously:

using var dynamicContext = new AssemblyResolver(Path.GetFullPath(opt.Assembly));
var assembly = dynamicContext.Assembly;

I pulled down the source code and reverted these changes to what they were previously, and everything worked again. It seems like the assembly resolver maybe shouldn't have been removed and the original issue might need to be addressed in another way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions