473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

reflection and bindingflags

How can I use reflection to inspect any assembly and get only the
methods written by the developers of the assembly, not all the built-
in methods. When I use GetMethods on the Module, it returns all the
built-in methods, so for a Form, I get
get_autosize, get_autoscroll, which I do not want. How can I filter
those out? I tried bindingflags,
but any combination of bindingflags returns an empty methodinfo
collection, e.g., "bindingflags.declaredonly or bindingflags.public
or
bindingflags.nonpublic."
Using framework 2.0 and vs2005.

Bill

Apr 22 '07 #1
2 1763
Bill,

Well, there is no such thing as a "built-in" method or property. Also,
the compiler doesn't know what you wrote vs something someone else wrote.

However, you are on the right track to get what you want. I imagine
that you are using ONLY the DeclaredOnly flag, when you need to declare the
Public and/or NonPublic flag, as well as the Static and/or Instance flag as
well. I think you are missing one of these.

Can you show the code you are using?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<bi*********@yahoo.comwrote in message
news:11**********************@e65g2000hsc.googlegr oups.com...
How can I use reflection to inspect any assembly and get only the
methods written by the developers of the assembly, not all the built-
in methods. When I use GetMethods on the Module, it returns all the
built-in methods, so for a Form, I get
get_autosize, get_autoscroll, which I do not want. How can I filter
those out? I tried bindingflags,
but any combination of bindingflags returns an empty methodinfo
collection, e.g., "bindingflags.declaredonly or bindingflags.public
or
bindingflags.nonpublic."
Using framework 2.0 and vs2005.

Bill

Apr 22 '07 #2
What I meant by built-in methods is that GetMethods with no
paramenters returns 493 methods for type Form1 that are not in my
source code. They appear to be all of Visual Studio's internal methods
for a standard Windows Form, like get_autosize and ValidateChildren. I
do use the DeclaredOnly bindings flag in conjunction with other flags,
as in "bindingflags.declaredonly or bindingflags.public or
bindingflags.nonpublic." My development machine is new and no
internet access until I get the firewall and anti-virus stuff set up,
so cannot supply the code without manually typing it.

Bill
On Apr 22, 10:49 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Bill,

Well, there is no such thing as a "built-in" method or property. Also,
the compiler doesn't know what you wrote vs something someone else wrote.

However, you are on the right track to get what you want. I imagine
that you are using ONLY the DeclaredOnly flag, when you need to declare the
Public and/or NonPublic flag, as well as the Static and/or Instance flag as
well. I think you are missing one of these.

Can you show the code you are using?

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<billsahi...@yahoo.comwrote in message

news:11**********************@e65g2000hsc.googlegr oups.com...
How can I use reflection to inspect any assembly and get only the
methods written by the developers of the assembly, not all the built-
in methods. When I use GetMethods on the Module, it returns all the
built-in methods, so for a Form, I get
get_autosize, get_autoscroll, which I do not want. How can I filter
those out? I tried bindingflags,
but any combination of bindingflags returns an empty methodinfo
collection, e.g., "bindingflags.declaredonly or bindingflags.public
or
bindingflags.nonpublic."
Using framework 2.0 and vs2005.
Bill- Hide quoted text -

- Show quoted text -

Apr 22 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
2
by: Lev | last post by:
Hi, I have some code that does reflection on an assembly I load. When I try to get the attributes on one of the methods implemented in the assembly, the MC++ version does not return anything....
0
by: Shawn Hogan | last post by:
Hi everyone, I've been trying to execute a control's private event code via reflection from another class with the goal of potentially doing some unit testing. The examples below are trying to...
2
by: Marco | last post by:
Hi, I try to use reflection to retrieve class B members and not inherited members. I wonder why the myMember value is nothing. Any suggestions? Thanks Module Module1 Sub Main()
15
by: satankidneypie | last post by:
Hi, I'm going to start this off with some code as it'll make it easier to explain afterwards... using System; namespace ConsoleApplication1 { /// <summary>
1
by: Chad Dollins | last post by:
I've got everything going nearly except one line of code. I think I'm in over my head here so, I'm going to ask for some help. Basically what the preposal is that you will be able to open a...
5
by: Klaudiusz Bryja | last post by:
Hi, This is for NetCF 2.0. I need to create event handling code which using reflection. I have some parameters in XML which describe how event should be handled. I have code to create...
0
by: Gustavo Arriola | last post by:
Hola a todos! Estoy intentando ejecutar un método usando Reflection. El código es el siguiente: public static void SoapHandler(Exception Error) { try { Type assemblyType;
6
by: chandramohanp | last post by:
Hi I am trying to modify class instance members using reflection. I am having problem when trying to add/remove/display elements related to List<int> member. Following is the code. class...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.