Embedded Resources in an abstract class

  • Thread starter Thread starter ramhog
  • Start date Start date
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.
 
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
 
Back
Top