Search:
Namespaces
Discussions
.NET v1.1
Feedback
Reflection FindMembers not working in Beta2
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngescalate' list
.
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.
Jesse Liberty (VIP)
I've received no answers to two postings in FreeForAll...
I've received a bug report on my book that has me baffled. I have two
examples, the first uses GetType to get a type and then GetMembers on that
type instance; works fine. The second gets the type and then uses
FindMembers. This used to work but no longer does. I've checked the
documentation and I can not figure out what is wrong. Here is the code...
namespace Programming_CSharp
{
using System;
using System.Reflection;
public class Tester
{
public static void Main()
{
// examine a single object
Type
theType T;ype.GetType(
"System.Reflection.Assembly");
// just members which are methods beginning with Get
MemberInfo
[] mbrInfoArray theType.FindMembers(
MemberTypes
.Method,
BindingFlags
.Default,
Type
.FilterName, "Get*"); // this no longer gets any
members!
foreach (
MemberInfo
mbrInfo in mbrInfoArray )
{
Console
.WriteLine("{0} is a {1}",
mbrInfo, mbrInfo.MemberType);
}
}
}
}
-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
http://www.LibertyAssociates.com
Reply to this message...
Saurabh Nandu (VIP)
Here you go . BUG Tested :-)
You *need* to specify the proper
BindingFlags
for this to work!! Also
the Instance and Declared
BindingFlags
are most important .other are
needed too
namespace Programming_CSharp
{
using System;
using System.Reflection;
public class Tester
{
public static void Main()
{
// examine a single object
Type
theType T;ype.GetType(
"System.Reflection.Assembly");
Console
.WriteLine(theType);
// just members which are methods beginning with Get
MemberInfo
[] mbrInfoArray theType.FindMembers(
MemberTypes
.Method,
BindingFlags
.Public |
BindingFlags
.Static |
BindingFlags
.NonPublic |BindingFlags.Instance |
BindingFlags
.DeclaredOnly,
Type
.FilterName, "Get*"); // this works!
foreach (
MemberInfo
mbrInfo in mbrInfoArray )
{
Console
.WriteLine("{0} is a {1}",
mbrInfo, mbrInfo.MemberType);
}
}
}
}
Regards,
Saurabh Nandu
Web Master:
http://www.MasterCSharp.com
<
http://www.mastercsharp.com/
>
Master C#, the easy way...
-----Original Message-----
From: Jesse Liberty [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, October 18, 2001 5:11 PM
To: aspngescalate
Subject: [aspngescalate] Reflection FindMembers not working in Beta2
I've received no answers to two postings in FreeForAll...
I've received a bug report on my book that has me baffled. I have two
examples, the first uses GetType to get a type and then GetMembers on
that type instance; works fine. The second gets the type and then uses
FindMembers. This used to work but no longer does. I've checked the
documentation and I can not figure out what is wrong. Here is the
code...
-------------------------------
Jesse Liberty
Liberty Associates, Inc.
.NET Training & Development
<
http://www.libertyassociates.com/
> http://www.LibertyAssociates.com
Reply to this message...
Jesse Liberty (VIP)
That fixed it perfectly, thanks!
-j
-----Original Message-----
From: Saurabh Nandu [mailto:
Click here to reveal e-mail address
]
Sent: Thursday, October 18, 2001 12:13 PM
To: aspngescalate
Subject: [aspngescalate] RE: Reflection FindMembers not working in Beta2
Here you go . BUG Tested J
You *need* to specify the proper
BindingFlags
for this to work!! Also the
Instance and Declared
BindingFlags
are most important .other are needed too
namespace Programming_CSharp
{
using System;
using System.Reflection;
public class Tester
{
public static void Main()
{
// examine a single object
Type
theType =
Type
.GetType(
"System.Reflection.Assembly");
Console
.WriteLine(theType);
// just members which are methods beginning with Get
MemberInfo
[] mbrInfoArray
theType.FindMembers(
MemberTypes
.Method,
BindingFlags
.Public |
BindingFlags
.Static |
BindingFlags
.NonPublic |BindingFlags.Instance |
BindingFlags
.DeclaredOnly,
Type
.FilterName, "Get*"); // this works!
foreach (
MemberInfo
mbrInfo in mbrInfoArray )
{
Console
.WriteLine("{0} is a {1}",
mbrInfo, mbrInfo.MemberType);
}
}
}
}
Regards,
Saurabh Nandu
Web Master:
http://www.MasterCSharp.com
Master C#, the easy way...
Reply to this message...
System.Console
System.Reflection.Assembly
System.Reflection.BindingFlags
System.Reflection.MemberInfo
System.Reflection.MemberTypes
System.Type
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