Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Property Reflection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Devin - 04 Aug 2005 00:14 GMT
I've never messed with Reflection at all, so I am unsure of where to start.
All of the documentation/articles I've found aren't helping much, or are too
complex for what I need.

All I need to do is take an assembly that only contains one type and
retrieve the value of a property (that has a known name).

I've tried using something like this that I found in some documentation:

       Dim x As [Assembly] = [Assembly].LoadFile("someAsm.dll")

       Dim t As Type = x.GetTypes(0)
       Dim m As PropertyInfo = t.GetProperty("propName")
       Dim obj As Object = Activator.CreateInstance(t)
       Dim i As Integer = m.GetValue(<ok what is supposed to go here?>)
     
I'm not sure what the getvalue method is supposed to take as arguments. Am I
even doing this right?

Thanks
Markus Stoeger - 04 Aug 2005 00:22 GMT
>         Dim x As [Assembly] = [Assembly].LoadFile("someAsm.dll")
>
[quoted text clipped - 4 lines]
>        
> I'm not sure what the getvalue method is supposed to take as arguments.

Give it the object that contains the property you want to get. In your
case thats "obj".

Max
Devin - 04 Aug 2005 00:43 GMT
right, that makes sense now that it's obvious. It's been a long day.

Well, anyway, I just decided to use an interface and some weird stuff
internal to the class in the assembly so that I can get values out. I had
wanted to use reflection because I wouldn't be able to know everything about
all of the properties until runtime.

Thank for you time though

> >         Dim x As [Assembly] = [Assembly].LoadFile("someAsm.dll")
> >
[quoted text clipped - 9 lines]
>
> Max

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.