Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unknown Error message

Status
Not open for further replies.

jadepatel

Technical User
Sep 4, 2002
35
0
0
GB
Hello,

I have this error message when i try to open a form.
My coding falls over on this line.....

Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Bitmap)

Infact even when i comment out this line it falls over on the next line that refernences an image.
Here is the error i am getting. does anyone know how to fix??.....

An unhandled exception of type 'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. Make sure "frmRes.resources" was correctly embedded or linked into assembly "MyProj".
baseName: frmRes locationInfo: MyProj.frmRes resource file name: frmRes.resources assembly: MyProj, Version=1.0.1550.16863, Culture=neutral, PublicKeyToken=null


I got some advise off someone previously but i do not know what they mean. Here is what they advised me to do....
"Make sure that the resource you're referencing
button2.image) is set as an embedded resource in your
solution"


Any help is appreciated
 
Here’s the code for dynamically adding image to Button control. Make sure you have added icon to your solution.

Private Sub ImageToButton(ByVal btn As Button, ByVal img As String)
'Declare a image variable of type Bitmap
Dim buttonImage As Bitmap
'Get a stream from the Assembly manifest resource
'Make sure that the Image that is included in the project has a build action of
'Embedded Resource
Dim imageStream As Stream = Me.GetType().Assembly.GetManifestResourceStream(img)
'Pass this stream inot the constructor of the bitmap
buttonImage = New Bitmap(imageStream)

'Set up the Image properties of the button
btn.TextAlign = ContentAlignment.MiddleRight
btn.Image = buttonImage
btn.ImageAlign = ContentAlignment.MiddleLeft
End Sub

Private Sub OnFormLoad(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'You need to specify the namespace to get to the resource
ImageToButton(btnImageButton, "SolutionName.IconName.ICO")
End Sub


Email: pankajmsm@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top