Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Automation and Extensibility
How to: Access Resources in Satellite DLLs

Once you have created a satellite DLL and added resources to it (icons, bitmaps, resource strings, and so forth), those resources now become available to your add-ins and other automation projects. The procedure below demonstrates how to do this.

NoteNote:

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. These procedures were developed with the General Development Settings active. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Accessing satellite DLL resources

  1. Open Visual Studio and either load an existing add-in project or create a new one.

  2. Add the following code example, compile, and run it.

The following is the general algorithm Visual Studio uses to find a satellite DLL. You can use this code to make sure that the satellite DLL is properly built, in the right location, and has the resource name you expect.

C#
static void Main(string[] args)
{
    string path = @"<some path here>";
    System.Reflection.Assembly asm =    
    System.Reflection.Assembly.LoadFrom(path);
    // For enhanced security, use the LoadFrom overload 
    // System.Reflection.Assembly.LoadFrom(path, securityInfo);
    // where securityInfo is an instance of an Evidence object.
    System.Reflection.Assembly assemblyForResources = 
    asm.GetSatelliteAssembly(System.Threading.
    Thread.CurrentThread.CurrentCulture);
    System.IO.Stream stream =    
    assemblyForResources.GetManifestResourceStream
    (assemblyForResources.GetManifestResourceNames()[0]);
    ResourceReader resReader = new ResourceReader(stream);
    foreach (System.Collections.DictionaryEntry entry in resReader)
    {
        System.Windows.Forms.MessageBox.Show(entry.Key.ToString());
    }
}

To use this example, create a Visual C# console application, add this code in place of the Main() function, and set the path variable to the path of the add-in assembly (not the path to the satellite DLL). When run, you will see all available resources in the satellite DLL.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker