Search:
Namespaces
Discussions
.NET v1.1
Feedback
get Relative Virtual Address (RVA) of a FieldInfo
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework.clr
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
Mehrdad (VIP)
Hello,
My question is related handling assemblies and IL files. I am trying to find
out a way to get the RVA of a field in an assembly and would appreciate any
help. Here is more details:
I load an assembly and get a Module. Then using GetFields(), I get the list
of static fields in that Module. The items of this list are of type
FiledInfo. Now the question is, when the "Attributes" property of one of
these FiledInfo items has a "HasFieldRVA", then how can I read the RVA of
that filed.
thanks,
--mehrdad
Reply to this message...
Ben Schwehn
[Original message clipped]
what are you using? the reflection api or the unamanged metadata api or
something else altogther?
when using the unmanaged metadata api you can call
HRESULT IMetaDataImport::GetRVA(mdToken tk, ULONG *pulCodeRVA, DWORD
*pdwImplFlags)
ignore the pdwImplFlags parameter, it's not used for fields.
--
Ben
http://bschwehn.de
Reply to this message...
Mehrdad (VIP)
Thanks Ben,
I am using C# and the managed API. I start with
Assembly
.LoadFrom(...). Is
this the right way? I think what you said is in SDK, can't I use the .NET
library itself for doing that?
If I'd better use the SDK, would you please tell me where to start from? Or
a link to a document or help file?
thank you very much,
--mehrdad.
"Ben Schwehn" wrote:
[Original message clipped]
Reply to this message...
Ben Schwehn
[Original message clipped]
Mehrdad,
I don't think you can use the reflection api to do that.
An helpful introduction to the Unmanaged API is in
http://www.iunknown.com/Files/metadata_internals.pdf
other than that look into the "Tool Developers Guide" folder in your
..net framework sdk folder.
Basically you can (after creating the com interfaces and doing an
OpenScope()) use the System.Reflection.
FieldInfo
.MetadataToken from the
FieldInfo
you got from GetFields and pass it to IMetaDataImport::GetRVA
good luck!
--
Ben
http://bschwehn.de
Reply to this message...
System.Reflection.Assembly
System.Reflection.FieldInfo
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com