Dependencies of dinamically loaded .dll are not found [Answered]

Hi everyone, I've an ASP.NET Core 6 web app where I have a main project "A" that, if certain conditions are meet, load dinamically an assembly B.dll. Now, let's say B depends upon some nuget package C (has a static reference to it). When, after B assembly has been loaded dinamically and during its code execution a class belonging to C is encountered, the program crashes since C is not found. I've noticed that, if I add to project A a static reference to C, everything works fine. Is there a way to fix this behavior without me having to add to project A static references to ALL dependencies of ALL the assemblies I want to load dinamically? Thanks
6 Replies
alkasel#159
alkasel#1592y ago
Actually I was able to fix .dll dependencies using this article https://www.codeproject.com/Articles/1194332/Resolving-Assemblies-in-NET-Core?msg=5895057#xx5895057xx I still miss how to do the same for nuget dependencies
CodeProject
Resolving Assemblies in .NET Core
How to resolve assemblies in .NET Core
Cisien
Cisien2y ago
Download the nuget, extract it, load the dll. You wont necessarily know from the assembly being loaded what nuget package its in Blindly installing nugets is rather dangerous
alkasel#159
alkasel#1592y ago
Ok, thanks
Mayor McCheese
You might want to look a custom assembly load contexts as well https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Accord
Accord2y ago
✅ This post has been marked as answered!