I follow http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx
I added WPFToolkit.Extended.dll to my solution and installed its Build Embedded Resource action.
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, because it is null.
I cannot use ILMerge because it is a WPF project.
epalm source share