Reputation: 3581
While building an Autofac Container, upon registering an interface implementation, Autofac would throw an exception:
protected override void Load(ContainerBuilder builder)
{
var assembly = typeof(MyModule).Assembly;
builder.RegisterAssemblyTypes(assembly)
.Where(x => x.Name.EndsWith("Procedure")
.AsImplementedInterfaces();
base.Load(builder);
}
Could not load type from assembly
Upvotes: 0
Views: 2163
Reputation: 3581
After searching Google, StackOverflow, Autofac documentation, and my soul, the closest I could find to my issue was this answer concerning the Global Assembly Cache (GAC) posted to this question concerning a container being build for testing purposes.
This lead me to think wrong assemblies. In our environment, we use Nuget packages frequently for our core interfaces and infrastructure. I checked that I was using the latest version of the package in my Service layer, so I was still stumped until I dug just a bit further.
In the end, the issue came down to the Nuget packages. The presentation layer of my solution, which was registering components via Autofac, had an outdated version of the Nuget package which contained the interface definitions. By updating the Nuget package in the presentation layer to match that of the Service layer, the problem disappeared.
Upvotes: 1