Kurt,
In addition to the other comments.
Rather then storing the icon in a .RESX file, I normally just embed the icon
directly, as its easier to maintain.
Shawn's article shows how to embed the icon directly & retrieve it. Plus
explains why its easier to maintain.
http://www.windojitsu.com/blog/resxsucks.html
My Xml Resource Resolver was written with XML in mind, however it can easily
be used with other resources, such as icons.
http://msmvps.com/jayharlow/archive/.../24/33766.aspx
To use my XmlResourceReso lver "as is" with an icon, use something like:
Public Module TestModule
Dim name As String
Dim resolver As New XmlResourceReso lver(GetType(Te stModule))
Dim absoluteUri As Uri = resolver.Resolv eUri(Nothing, name)
Dim input As Stream = DirectCast(reso lver.GetEntity( absoluteUri,
Nothing, Nothing), Stream)
Dim theIcon As New Icon(input)
End Module
Alternatively you could just extract most of the GetEntity method into its
own class (which gives you a class similar to Shawn's). Something like:
Option Strict On
Option Explicit On
Imports System.IO
Imports System.Globaliz ation
Imports System.Reflecti on
Public Class ResourceLoader
Private ReadOnly m_assembly As [Assembly]
Private ReadOnly m_type As Type
Public Sub New(ByVal type As Type)
m_assembly = type.Assembly
m_type = type
End Sub
Public ReadOnly Property Location() As String
Get
Return m_assembly.Loca tion
End Get
End Property
Public Function GetStream(ByVal name As String) As Stream
Dim culture As CultureInfo = CultureInfo.Cur rentUICulture
Dim stream As Stream
' Try the specific culture
stream = GetManifestReso urceStream(cult ure, name)
' Try the neutral culture
If stream Is Nothing AndAlso Not culture.IsNeutr alCulture Then
stream = GetManifestReso urceStream(cult ure.Parent, name)
End If
' Try the default culture
If stream Is Nothing Then
stream = GetManifestReso urceStream(name )
End If
If stream Is Nothing Then
Throw New FileNotFoundExc eption(Nothing, name)
End If
Return stream
End Function
Private Function GetManifestReso urceStream(ByVa l culture As CultureInfo,
ByVal name As String) As Stream
Try
Dim satellite As [Assembly] =
m_assembly.GetS atelliteAssembl y(culture)
Return satellite.GetMa nifestResourceS tream(m_type, name)
Catch ex As FileNotFoundExc eption
Return Nothing
End Try
End Function
Private Function GetManifestReso urceStream(ByVa l name As String) As
Stream
Return m_assembly.GetM anifestResource Stream(m_type, name)
End Function
End Class
Hope this helps
Jay
"kurt sune" <ap*@apa.cx> wrote in message
news:uW******** *****@TK2MSFTNG P12.phx.gbl...
Anybody has a tip of where to find info/example how to retrieve an icon
from a .RESX-file?
/k