J
JL
My project has a series of icons; 20x20 pictureboxes populated with
bitmaps. The bitmaps/images come from a DLL. The VB.NET DLL that is
called has a form in it, which has pictureboxes containing each
available picture. A picture is requested from the DLL as follows:
Public Function ReturnIcon() As Object
Return New frmImages().picLiteOn.Image
End Function
Because of the technique used to call the DLL, the return must be an
object. (that's a whole other story) The code in the program requests
the picture from the DLL as follows:
Dim OBJ As Object = New DLLName.Class1().ReturnIcon
Dim BMP As Bitmap
Try
BMP = CType(OBJ, Bitmap)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
CType(CTRL, PictureBox).Image = BMP
The program "crashes" on BMP=CType(OBJ,Bitmap) with this error:
System.InvalidCastException: Specified cast is not valid.
The interesting thing is, if I step through the code, after the error,
I can go to the Command Window and type in BMP=CType(OBJ,Bitmap), it
is accepted and the picture box loads with no errors.
Any suggestions?
Thx. JL.
bitmaps. The bitmaps/images come from a DLL. The VB.NET DLL that is
called has a form in it, which has pictureboxes containing each
available picture. A picture is requested from the DLL as follows:
Public Function ReturnIcon() As Object
Return New frmImages().picLiteOn.Image
End Function
Because of the technique used to call the DLL, the return must be an
object. (that's a whole other story) The code in the program requests
the picture from the DLL as follows:
Dim OBJ As Object = New DLLName.Class1().ReturnIcon
Dim BMP As Bitmap
Try
BMP = CType(OBJ, Bitmap)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
CType(CTRL, PictureBox).Image = BMP
The program "crashes" on BMP=CType(OBJ,Bitmap) with this error:
System.InvalidCastException: Specified cast is not valid.
The interesting thing is, if I step through the code, after the error,
I can go to the Command Window and type in BMP=CType(OBJ,Bitmap), it
is accepted and the picture box loads with no errors.
Any suggestions?
Thx. JL.