I am trying to use the AssemblyResolve method to load embedded assemblies. However one of these appears to refer to itself, and so when trying to load it, it calls the AssemblyResolve again.
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("AnalysisViewer.Embedded_DLLs.{0}.dll", new AssemblyName(args.Name).Name)))
{
if (stream == null)
return null;
byte[] assemblyData = new byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
Is there a way round this? The dll being loaded is a DevExpress one, so I cannot do anything about the code in that, and it loads fine if I have it as a standard dll.
I can revert to distributing this dll with the package, but we are trying to get a single file drop installation, if possible.
This is the stack trace I get:
AnalysisViewer.exe!AnalysisViewer.App.OnStartup.AnonymousMethod__0(object sender, System.ResolveEventArgs args)
mscorlib.dll!System.AppDomain.OnAssemblyResolveEvent(System.Reflection.RuntimeAssembly assembly, string assemblyFullName)
[Native to Managed Transition]
mscorlib.dll!System.AppDomain.OnAssemblyLoadEvent(System.Reflection.RuntimeAssembly LoadedAssembly)
[Native to Managed Transition]
mscorlib.dll!System.Reflection.Assembly.Load(byte[] rawAssembly)
AnalysisViewer.exe!AnalysisViewer.App.OnStartup.AnonymousMethod__0(object sender, System.ResolveEventArgs args)