reflection VB2003 to VB2005

  • Thread starter Thread starter DK
  • Start date Start date
D

DK

I have the following line in a VB2003 program that I'm converting to
VB2005 and it gives a warning about Access of Shared member will not
be evaluated --- what do I need to do to do away with the warning?

Private m_BmpStream As Stream
Private m_Assembly As System.Reflection.Assembly = _
Me.GetType.Assembly.GetEntryAssembly()

This is later used in order to retrieve a bitmap logo:

m_BmpStream = _
m_Assembly.GetManifestResourceStream("Portal.logo.bmp")
 
The compiler should suggest you a fix such as :
Reflection.Assembly.GetEntryAssembly()



The idea is that the getEntryAssembly is a shared method and the compiler
now prefers to have those class level methods being called through the class
rather than through one of its instance.
 
I have the following line in a VB2003 program that I'm converting to
VB2005 and it gives a warning about Access of Shared member will not
be evaluated --- what do I need to do to do away with the warning?

Private m_BmpStream As Stream
Private m_Assembly As System.Reflection.Assembly = _
Me.GetType.Assembly.GetEntryAssembly()

This is later used in order to retrieve a bitmap logo:

m_BmpStream = _
m_Assembly.GetManifestResourceStream("Portal.logo.bmp")

Not sure off the top of my head, but I believe
GetManifestResourceStream is a shared method. If so you should access
it through the type and not the instance.

Like so:

m_BmpStream =
System.Reflection.Assembly.GetManifestResourceStream("Portal.logo.bmp")

If this doesn't fix the problem let me know and I'll actually open up
VS and look at it more in depth.

Thanks,

Seth Rowe
 
Not sure off the top of my head, but I believe
GetManifestResourceStream is a shared method. If so you should access
it through the type and not the instance.

Like so:

m_BmpStream =
System.Reflection.Assembly.GetManifestResourceStream("Portal.logo.bmp")

If this doesn't fix the problem let me know and I'll actually open up
VS and look at it more in depth.

Thanks,

Seth Rowe

Thanks for the help it fixed the problem.
 
Back
Top