Reflection

N

Nico Debeuckelaere

Hi all,

I have a class in VB.NET in an assembly like:
----------------------------------
Public MustInherit Class MyBaseClass
Public Function GetBitmap(Name As String) As System.Drawing.Bitmap
Dim img As System.Drawing.Bitmap
Dim p As System.Reflection.Assembly = _
System.Reflection.Assembly.GetExecutingAssembly
img = New
System.Drawing.Bitmap(p.GetManifestResourceStream(Me.GetType, Name))
img.MakeTransparent()

Return img
End Function

Public MustOverride Property Name() As String
End Class
------------------------------------

Then I have a class in a seperate assembly that inherits the previously
created class:

----------------------------------
Public Class MyImplementedClass
Inherits MyBaseClass

Public Overrides Property Name() As String
Get
Return "MyImplementedClass"
End Get
End Property
End Class
------------------------------------------

The MyImplemented class has also some bitmap files defined as Embedded
Resource.
Now ... what I want to do is return a bitmap with a given name by calling
MyImplementedClass.GetBitmap("myimplementedclass.bmp")
When I look at the variable p in the function GetBitmap, it return the
assembly location refering to MyBaseClass and not the location of
MyImplementedClass.
How can I reflect to the MyImplementationClass?

Regards,
ND
 
M

Mattias Sjögren

How can I reflect to the MyImplementationClass?
Change

Dim p As System.Reflection.Assembly = _
System.Reflection.Assembly.GetExecutingAssembly


to

Dim p As System.Reflection.Assembly = Me.GetType().Assembly



Mattias
 

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