Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Retrieving Icons Embedded in Assemblies

Retrieving Icons Embedded in Assemblies

Scheduled Pinned Locked Moved .NET (Core and Framework)
comhardware
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bneacetp
    wrote on last edited by
    #1

    I am working on an application and need to be able to have the application have the ability to "look into" an assembly and list out the icons which are compiled into it. Any points into the right direction would be greatly appreciated. :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/

    T 1 Reply Last reply
    0
    • B bneacetp

      I am working on an application and need to be able to have the application have the ability to "look into" an assembly and list out the icons which are compiled into it. Any points into the right direction would be greatly appreciated. :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      All embedded icons will turn up as resources in the assembly with the .ico extension. The only tricky bit is that VS.Net adds the DefaultNamespace to the front of the icon file name when it compiles the assembly so you have to chop that off. Here is an example showing how you would do this using the current assembly, and display the list in a messagebox. To run on another assembly simply use Assembly.LoadFrom() to get a pointer to it.

          Dim TestAssembly As \[Assembly\] = System.Reflection.Assembly.GetExecutingAssembly
          Dim namesList As String() = TestAssembly.GetManifestResourceNames
      
          '   Fudge to get the default Namespace for the assembly.
          Dim currentNameSpace As String = \[String\].Empty
          currentNameSpace = TestAssembly.GetTypes(0).Namespace
          If currentNameSpace.Length > 0 Then
              currentNameSpace &= "."
          End If
      
      
          Dim list As String = \[String\].Empty
      
          Dim names As IEnumerator = namesList.GetEnumerator
          While names.MoveNext
              If names.Current.ToString().ToLower().EndsWith(".ico") Then
                  list &= names.Current.ToString().Replace(currentNameSpace, "") & System.Environment.NewLine
              End If
          End While
      
          MessageBox.Show(list)
      

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850)

      B 1 Reply Last reply
      0
      • T The Man from U N C L E

        All embedded icons will turn up as resources in the assembly with the .ico extension. The only tricky bit is that VS.Net adds the DefaultNamespace to the front of the icon file name when it compiles the assembly so you have to chop that off. Here is an example showing how you would do this using the current assembly, and display the list in a messagebox. To run on another assembly simply use Assembly.LoadFrom() to get a pointer to it.

            Dim TestAssembly As \[Assembly\] = System.Reflection.Assembly.GetExecutingAssembly
            Dim namesList As String() = TestAssembly.GetManifestResourceNames
        
            '   Fudge to get the default Namespace for the assembly.
            Dim currentNameSpace As String = \[String\].Empty
            currentNameSpace = TestAssembly.GetTypes(0).Namespace
            If currentNameSpace.Length > 0 Then
                currentNameSpace &= "."
            End If
        
        
            Dim list As String = \[String\].Empty
        
            Dim names As IEnumerator = namesList.GetEnumerator
            While names.MoveNext
                If names.Current.ToString().ToLower().EndsWith(".ico") Then
                    list &= names.Current.ToString().Replace(currentNameSpace, "") & System.Environment.NewLine
                End If
            End While
        
            MessageBox.Show(list)
        

        If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850)

        B Offline
        B Offline
        bneacetp
        wrote on last edited by
        #3

        Thanks for the help! :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups