I'm following http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
I've added WPFToolkit.Extended.dll to my solution, and set its Build Action to Embedded Resource.
In App.OnStartup(StartupEventArgs e) I have the following code:
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
String resourceName = "AssemblyLoadingAndReflection." + new AssemblyName(args.Name).Name + ".dll";
String assemblyName = Assembly.GetExecutingAssembly().FullName;
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
using (stream)
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
The debugger hits this block of code twice.
First time:
resourceName is "AssemblyLoadingAndReflection.StatusUtil.resources.dll"
assemblyName is "StatusUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
stream is null
Second time:
resourceName is "AssemblyLoadingAndReflection.WPFToolkit.Extended.resources.dll"
assemblyName is "StatusUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
stream is null
The code throws an exception when it hits stream.Length, since it's null.
I can't use ILMerge because it's a WPF project.