I created a chart C# library (let's call it chartlibrary
) which itself has dependencies on multiple third-party dll files.
In another executable project (let's call it chartuser
), I reference the chartlibrary
project (both projects sit within the same solution in Visual Studio).
Upon compilation, I can see that all the third-party dll files that chartlibrary
references are also contained in the bin/Debug folder of chartuser
. However, I get a runtime error which basically points to the fact that some of the references in chartlibrary
cannot be resolved. I then tried to get a better idea via
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
and
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var assemblyFileName = args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll";
var assemblyPathFileName = _currentPluginPath + @"\" + assemblyFileName;
if (File.Exists(assemblyPathFileName))
{
return Assembly.Load(File.ReadAllBytes(assemblyPathFileName));
}
return null;
}
Problem is that the RequestingAssembly
is null and Name
is very cryptic.
What am I doing wrong that the reference dlls cannot be found and assemblies cannot be resolved even though all the dlls are in the bin/Debug folder of the executable project?