Reputation: 7207
I'm trying to load an assembly and create classes from it dynamically. This is the code:
assembly = Assembly.Load(assemblyName);
var type = assembly.GetType(assemblyName + ".MessageProcessor");
var processor = (IMessageProcessor)Activator.CreateInstance(type);
processor.Process();
The problem is that the assembly name belongs to an assembly that is not referenced in the project. I deploy it manually to the execution folder.
But I receive this error:
Could not load file or assembly 'AssemblyNameToLoad, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
I can't manually add all of these files to deps.json
. Is there a way to make .NET Core load assembly in spite of not being present in deps.json
file?
Upvotes: 3
Views: 630
Reputation: 7692
LoadFrom should solve your problem as it loads a "physical" file.
I should add that you still have to communicate with it so some knowledge about it is prefereable, unless you want to go all reflection, so both loader and loaded should reference the same contract project.
Upvotes: 2