Questions tagged [bindingflags]
18 questions
257
votes
3 answers
BindingFlags.IgnoreCase not working for Type.GetProperty()?
Imagine the following
A type T has a field Company.
When executing the following method it works perfectly:
Type t = typeof(T);
t.GetProperty("Company")
Whith the following call I get null though
Type t = typeof(T);
t.GetProperty("company",…

Boris Callens
- 90,659
- 85
- 207
- 305
25
votes
7 answers
Not getting fields from GetType().GetFields with BindingFlag.Default
I am using the Reflection classes in order to get all the fields inside a certain object.
My problem however is that it works perfectly when the fields are inside a normal class, like:
class test
{
string test1 = string.Empty;
string test2 =…

Patrick
- 1,763
- 5
- 18
- 16
15
votes
2 answers
What is BindingFlags.Default equivalent to?
I remember reading somewhere, when using reflection and the overload of GetMethod that accepts a bitmask of BindingFlags, that BindingFlags.Default is equivalent to BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance or something. Can…

Big McLargeHuge
- 14,841
- 10
- 80
- 108
4
votes
1 answer
Accessing a seemingly public property through reflection
Good day all,
I am struggling to determine what's the issue with an attempt to access a public property on a class.
My need is very basic. I have a public class that's correctly instanced in my routine, and I know, thanks to reflector, that this…

roamcel
- 645
- 1
- 8
- 17
2
votes
1 answer
Get ReturnParameter's Name property of a RuntimeMethodInfo object using Reflection (C#)
Suppose i have the following class in C#:
public class B : A
{
public Int32 B_ID;
public String B_Value;
public Int32 getID()
{
return B_ID;
}
public void setID(Int32 value)
{
B_ID = value;
…

rsfurlan90
- 31
- 1
- 7
2
votes
1 answer
See if MemberInfo matches BindingFlags using C#
I need to see if a MemberInfo matches a particular BindingFlags. The closest method to this is Type#GetMember(string, BindingFlags).
I cannot find any method to do this.
I want to do something like this:
private List _members;
public…

ChristopherIsFun
- 93
- 2
- 10
2
votes
1 answer
BindingFlags for methods with Attributes
Is it possible to use the BindingFlags for methods that have attributes? I did look over msdn at BindingFlags and nothing showed up.
This is how one of my methods looks like :…

ExtremeSwat
- 794
- 1
- 12
- 34
2
votes
3 answers
How to exclude static property when using GetProperties method
I was wonder if I can exclude static property when I'm using GetProperties() to extract all the property for a specific class. I'm aware of using BindingFlags for this to filter properties what I need but what I really want is that I want to exclude…

Rob
- 638
- 3
- 14
- 34
1
vote
3 answers
Filter "own members" with BindingFlags
I got the following code :
public class PluginShape : INotifyPropertyChanged
{
private string _Name;
public string Name
{
get { return _Name; }
set
{
_Name = value;
…

Guillaume Slashy
- 3,554
- 8
- 43
- 68
1
vote
2 answers
Issue with system.reflection, GetFields not returning everything
Im having a bit of an issue with System.Reflection. Please see the attached code:
class Program
{
public static FieldInfo[] ReflectionMethod(object obj)
{
var flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public…

ASMoncrieff
- 27
- 4
1
vote
2 answers
How to get custom a list of methods with reflection in C#
I have being using reflection to create a list of methods that the user would use in a dynamic generated menu (I'am in unity). I'am using:
MethodInfo[] methodInfos = myObject.GetMethods(BindingFlags.Public | BindingFlags.Instance |…

Emiliano
- 39
- 1
- 7
0
votes
1 answer
C# InvokeMember - MissingMethodException: 'Method not found'
In a .NET Core 6 RestAPI application, I'm tracking global stock exchanges and have an instance of the below Exchange class called "ex".
public class Exchange
{
public string CountryCode { get; set; }
public string Currency { get; set; }
…

PaulPerkins
- 113
- 3
- 12
0
votes
0 answers
Escape from sandbox: reflection
I have really fun problem. It's kind of sandbox escaping.
Aim: get private methods of class
What I can:
1) Load standart assemblies by assemblies by long name
2) Use GetType and Type's methods
What I cannot:
1) Use using in code
2) Use System…

fryday
- 387
- 2
- 14
0
votes
1 answer
Does the Pipe in binding flags not represent an 'OR'
I am currently debugging in the immediate window:
-
This returns 0 properties:
type.GetProperties(BindingFlags.Instance)
This also returns 0 properties:
type.GetProperties(BindingFlags.Public)
But this returns both…

Kieran
- 612
- 6
- 22
0
votes
1 answer
How to I get the parent property's class type after using GetProperties to get a list of properties on a class?
I'm using GetProperties to get a list of properties for a class.
Dim properties As List(Of PropertyInfo) = objType.GetProperties(BindingFlags.Instance Or BindingFlags.Public).ToList()
For Each prop As PropertyInfo In properties
'how do I get the…

thecoolmacdude
- 2,036
- 1
- 23
- 38