title: Using reflection in C# to try and access My.Resources
body: <p>I have inherited a large project written in a mixture of C# and VB.Net</p>
  
  <p>The project involves many separate assemblies.</p>
  
  <p>There are hundreds (or thousands) of resources (png files) that have been inserted into the project using the VB My.Resources functionality that I would like to access from some C# code, in a different assembly.</p>
  
  <p>Microsoft has a <a href="http://msdn.microsoft.com/en-us/library/aa984408%28VS.71%29.aspx" rel="nofollow">KB article</a> about this. It includes some sample code, but I  can't get it to work (and I can't quite follow the code). </p>
  
  <pre><code>// Gets a reference to the same assembly that 
  // contains the type that is creating the ResourceManager.
  System.Reflection.Assembly myAssembly;
  myAssembly = this.GetType().Assembly;
  
  // Gets a reference to a different assembly.
  System.Reflection.Assembly myOtherAssembly;
  myOtherAssembly = System.Reflection.Assembly.Load("ResourceAssembly");
  
  // Creates the ResourceManager.
  System.Resources.ResourceManager myManager = new 
      System.Resources.ResourceManager("ResourceNamespace.myResources", myAssembly);
  
  // Retrieves String and Image resources.
  System.String myString;
  System.Drawing.Image myImage;
  myString = myManager.GetString("StringResource");
  myImage = (System.Drawing.Image)myManager.GetObject("ImageResource");
  </code></pre>
  
  <p>I can't follow why the code creates <strong>myAssembly</strong> and <strong>myOtherAssembly</strong> and never seems to use the second object?</p>
  
  <p>Does the action of loading the second assembly...</p>
  
  <pre><code>myOtherAssembly = System.Reflection.Assembly.Load("ResourceAssembly");
  </code></pre>
  
  <p>...mean I don't need to reference it further down when I create a <strong>ResourceManager</strong> ?</p>
  
  <pre><code>System.Resources.ResourceManager myManager = new 
      System.Resources.ResourceManager("ResourceNamespace.myResources", myAssembly);
  </code></pre>
  
  <p>Any idea how I can access these resources (with or without reflection) would be greatly appreciated!</p>