Conversion from Object to System.Drawing.Image

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?
 
K

Ken Tucker [MVP]

Hi,

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

Ken
 
A

andycool1

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top