How to add an icon to your component

When developing your own custom components for that more professional, and also practical, finish you may want to use your own icon rather than relying on the default system icon. You set this through the IconResource property of the appropriate component attribute; DtsTask for a control flow component or task, DtsPipelineComponent for a data flow component, and DtsConnection for your own connection manager. The DtsConnection IconResource functionality is not fully implemented, and you will always get the default icon.

To set an icon for your component the first thing you need to do is to prepare your icon. This should contain two images, one 16×16 for the toolbox and one 32×32 for the design surface. Best practice for icon design states that you should provide several colour depths, however in practice I find 256 colours is sufficient, although this is contrary to current Books Online topics which state 16 colours.

A full discussion of icon design is beyond the scope of this article, however there are a wide range of tools and resources available on the Internet. For a detailed explanation of current icon design practices try Creating Windows XP Icons.

Using Visual Studio 2005 add the icon to your project if you haven’t already. Right-click the project in the Solution Explorer and select Add, Existing Item…. Change the file filter to All files, and then select your icon file. Once the icon is listed in the Solution Explorer, check the properties, and ensure you set the Build Action to Embedded Resource.

You now need to determine the icon resource string for the icon. This is made up of the project’s default namespace and the filename of the icon. For example if the default namespace is SQLIS.Dts.Pipeline.MyComponent and the icon filename is MyIcon.ico, the resource string would be SQLIS.Dts.Pipeline.MyComponent.MyIcon.ico.

If the icon is placed in a subfolder within the project this will change the resource string slightly, as the folder will become part of the namespace. So if the icon is within a folder called Graphics in the project, the resource string becomes SQLIS.Dts.Pipeline.MyComponent.Graphics.MyIcon.ico.

Once you have determined the resource string you set the IconResource property of your component attribute. For simplicity we use an icon without a folder for the examples below.

A C# example of setting a source adapter pipeline component –

  DisplayName = "MyComponent Source",        
  ComponentType = ComponentType.SourceAdapter,      
  IconResource = "SQLIS.Dts.Pipeline.MyComponent.MyIcon.ico")]
public class MyComponent : PipelineComponent ...

A VB.Net example of setting a source adapter pipeline component –

<DtsPipelineComponent( _
    DisplayName:="My Component Source", _    
    ComponentType:=ComponentType.SourceAdapter, _
    IconResource:="SQLIS.Dts.Pipeline.MyComponent.MyIcon.ico")> _ 
Public Class MyComponent    
    Inherits PipelineComponent...


If you are still having problems getting your icon to be displayed correctly, the first thing to check is the resource string. If it still looks correct then you can take it one step further and look inside the compiled assembly to find out what is really going on. For this we need to use the MSIL Disassembler tool, ILDASM.exe. For a further explanation of MSIL and the ILDASM tool refer to the Visual Studio help system. For our purposes open a Visual Studio Command Prompt and type ildasm. This opens the tool and you can then select your assembly, through the File, Open menu options or just drag and drop the file into the window. We are interested in the manifest information, so double click the M A N I F E S T icon in the ILDASM window.

A new window will open displaying the manifest information. Scroll down until you find the mresource directives, with are normally almost at the end. If you have set your icon to be an embedded resource correctly, then you will see the resource string which needs to match what is set in the IconResource property of the component attribute.

A snippet of a manifest continuing with the sample scenario from above –

.mresource public SQLIS.Dts.Pipeline.MyComponent.MyIcon.ico{}


If the resource string looks wrong then check the namespace in Project Properties, as this may differ from what has been coded in your class files leading to the confusion.

To allow the designer to add your component to the toolbox you will need to Reset Toolbox, available from the tool box context menu, Right-click. If the component has previously been added the icon will not be updated without a second Reset Toolbox. The design sheet icon will be updated just by restarting the Business Intelligence Development Studio application.