| 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
dotnetCLI (.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
- Read the exception message at the end of the diagnostic message: it usually names the missing file or the incompatible dependency.
- 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 --clearfollowed bydotnet restore. - If you're the author of the extension, check the
MetalamaExtensionAssemblyitems of your package: the paths must exist, and theTargetFrameworkandTargetRoslynVersionmetadata must select a build that matches the process that loads it.