Open sandboxFocusImprove this doc

LAMA0070: An extension assembly can't be loaded

Severity Error
Reported by Metalama.Framework
Message Cannot load the extension assembly '<Path>': <ExceptionMessage>

Cause

Packages can extend Metalama itself, for instance to provide services to aspects, by registering extension assemblies with the MetalamaExtensionAssembly or MetalamaDesignTimeExtensionAssembly MSBuild items. Metalama loads these assemblies when it compiles the project and looks for the extensions they export with ExportExtensionAttribute.

Metalama reports LAMA0070 when it can't load one of these assemblies, or can't read its custom attributes. In the message, <Path> is the path or the name of the assembly, and <ExceptionMessage> is the message of the exception thrown by the loader. Typical reasons are:

  • The file doesn't exist, for instance because the package is corrupted or the path in the MSBuild item is wrong.
  • The assembly was built for a different target framework or a different version of Roslyn than the process that runs Metalama, such as Visual Studio (.NET Framework) or the dotnet CLI (.NET).
  • A dependency of the extension assembly is missing or has an incompatible version.

This diagnostic depends on the packages and the files installed on the machine, so it can't be shown in an example.

Resolution

  1. Read the exception message at the end of the diagnostic message: it usually names the missing file or the incompatible dependency.
  2. If the assembly comes from a package, check that the version of the package is compatible with your version of Metalama, then clear the local package cache and restore the packages again, for instance with dotnet nuget locals all --clear followed by dotnet restore.
  3. If you're the author of the extension, check the MetalamaExtensionAssembly items of your package: the paths must exist, and the TargetFramework and TargetRoslynVersion metadata must select a build that matches the process that loads it.

See also