Embedded Resources in vb.net

i have several chess pieces that are named like so "BasicBPawn.ico" and are embedded resources in a file
i'm trying to retrieve them like so....


Public Sub New()
MyBase.New()

Dim chessAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim assemblyName As String = chessAssembly.GetName().Name
Dim imageName As String
Dim imageStream As System.IO.Stream

Dim rankNames() As String = System.Enum.GetNames(System.Type.GetType("BnPayne.Chess.Pieces.Rank"))

Dim intPlayer As Table.Player
Dim intRank As Short

For intPlayer = 0 To 1
For intRank = 0 To rankNames.Length - 1
imageName = assemblyName & "." & Me.Style & mAllegiances(intPlayer).ToString.Chars(0) & rankNames(intRank) & ".ico" '
imageStream = chessAssembly.GetManifestResourceStream(imageName)

mPieceImages(intPlayer, intRank) = New Icon(imageStream)

Next intRank
Next intPlayer

'set's piece 0 in any to the abstract piece
Me.AddPiece(Rank.Abstract, Player.None, -1)
End Sub

this is my error
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll

Additional information: 'null' is not a valid value for 'stream'.

the bold is where the error occurs

any help?
brandon

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories