Open sandboxFocusImprove this doc

LAMA0290: Two versions of an aspect library provide the same aspect type

Severity Error
Reported by Metalama.Framework
Message The aspect type '<AspectType>' was found in two different versions of the same referenced assembly. Make sure that all references to this assembly use the same version.

Cause

When Metalama compiles a project, it collects the aspect types from the compile-time code of the project itself and of the assemblies that the project references, directly or indirectly. Each aspect type is identified by its full name.

Metalama reports LAMA0290 when two of these assemblies have the same name but different versions, and both define an aspect type with the same full name. Metalama can't decide which of the two aspect classes to use. In the message, <AspectType> is the full name of the aspect type.

This situation typically arises when the project references one version of an aspect library and another reference brings a different version of the same library, for instance a file reference to an outdated copy of the assembly.

This diagnostic depends on references to several versions of an assembly, so it can't be shown in an example.

Resolution

Make sure that only one version of the assembly reaches the compilation:

  1. Identify the assembly that defines the aspect type given in the message.
  2. Check the references of the project, including indirect ones, for different versions of this assembly. In Visual Studio, expand Dependencies in Solution Explorer. On the command line, run dotnet list package --include-transitive.
  3. Align all references to the same version, for instance by updating the package in all projects or by defining its version in a single place with central package management. Remove any file reference that points to an outdated copy of the assembly.
  4. Rebuild the project.

See also