Note that there are some explanatory texts on larger screens.

plurals
  1. POIncluding a DLL as an Embedded Resource in a WPF project
    text
    copied!<p>I'm following <a href="http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx" rel="nofollow">http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx</a></p> <p>I've added WPFToolkit.Extended.dll to my solution, and set its Build Action to Embedded Resource.</p> <p>In App.OnStartup(StartupEventArgs e) I have the following code:</p> <pre><code>AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =&gt; { 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); } }; </code></pre> <p>The debugger hits this block of code twice.</p> <p>First time:</p> <pre><code>resourceName is "AssemblyLoadingAndReflection.StatusUtil.resources.dll" assemblyName is "StatusUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" stream is null </code></pre> <p>Second time:</p> <pre><code>resourceName is "AssemblyLoadingAndReflection.WPFToolkit.Extended.resources.dll" assemblyName is "StatusUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" stream is null </code></pre> <p>The code throws an exception when it hits stream.Length, since it's null.</p> <p>I can't use ILMerge because it's a WPF project.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload