Conversion from Object to System.Drawing.Image

  • Thread starter Thread starter andycool1
  • Start date Start date
A

andycool1

I get the following error in my code when I set Option Strict to On:
Option Strict On disallows implicit conversions from 'System.Object'
to 'System.Drawing.Image'

The blue error underline starts at "ResMan" and goes to the end of the
line in this line of code:
Dim i As System.Drawing.Image = ResMan.GetObject("logo.gif")

ResMan is declared in another module as follows:
Public ResMan As New Resources.ResourceManager("DemoProject.Images",
System.Reflection.Assembly.GetCallingAssembly)


I can see that the GetObject method returns an Object and I need a
System.Drawing.Image, but how do I do the explicit conversion?
 
Hi,

Dim i As System.Drawing.Image = CType(ResMan.GetObject("logo.gif"),Image)

Ken
 
I can't try that out yet (the project is in a virtual machine that just
got moved off of my laptop), but I'll assume it works and say thank-you
very much. I don't know how I missed such a simple solution.
 
Back
Top