Embedded Resources in an abstract class

R

ramhog

I have an abstract class "TestClass" in a project. In the project
there are several icon files that are set to be an embedded
resource. In the abstract class is a private method attempting to
use one of the embedded icons. When I attempt to create the icon by
using
ctrl.Image = new Bitmap(GetType(), "TestClass.MyIcon.ico");
I get an error that the icon can't be found. The part I don't
understand is the error says the icon can't be found in the project
that is deriving from this base class. Why is it trying to look in
the derived project for the icon instead of the TestClass project
which is where I added the icons?

Any help will be appreciated.
 
L

Laurent Bugnion [MVP]

Hi,
I have an abstract class "TestClass" in a project. In the project
there are several icon files that are set to be an embedded
resource. In the abstract class is a private method attempting to
use one of the embedded icons. When I attempt to create the icon by
using
ctrl.Image = new Bitmap(GetType(), "TestClass.MyIcon.ico");
I get an error that the icon can't be found. The part I don't
understand is the error says the icon can't be found in the project
that is deriving from this base class. Why is it trying to look in
the derived project for the icon instead of the TestClass project
which is where I added the icons?

Any help will be appreciated.

Probably because GetType() returns the Type of the derived class, not of
the abstract base class.

Try to use typeof( TestClass ) instead.

Greetings,
Laurent
 

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