79555816

Date: 2025-04-04 16:09:03
Score: 0.5
Natty:
Report link

Reading files in the folder where an MSIX package is deployed needs to be done in a way that may not alter the files. As such, we found a way to make the code work, by replacing

catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory));

by

string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ??AppDomain.CurrentDomain.BaseDirectory;

foreach (string file in Directory.GetFiles(path, "*.dll"))
{
    catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(file)));
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: B. Bram