473,671 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d eclaredonly or bindingflags.pu blic
or
bindingflags.no npublic."
Using framework 2.0 and vs2005.

Bill

Apr 22 '07 #1
2 1771
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.co m

<bi*********@ya hoo.comwrote in message
news:11******** **************@ e65g2000hsc.goo glegroups.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.d eclaredonly or bindingflags.pu blic
or
bindingflags.no npublic."
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 ValidateChildre n. I
do use the DeclaredOnly bindings flag in conjunction with other flags,
as in "bindingflags.d eclaredonly or bindingflags.pu blic or
bindingflags.no npublic." 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.guar d.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.c om

<billsahi...@ya hoo.comwrote in message

news:11******** **************@ e65g2000hsc.goo glegroups.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.d eclaredonly or bindingflags.pu blic
or
bindingflags.no npublic."
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
3690
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 discuss how reflection does this, but I cannot find the syntax to do this. I have tried several code example off of gotdotnet and other articles. Can somebody please show me the code to do this?
10
7360
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 Windows.Forms.UserControl in a COM environment, i.e. I want to host that control in a COM host. So far, so good, I can host it, but I can not reach the parent COM object from the control (Parent property is null :( ). I have stopped the control in the...
2
1908
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. See code below: Object __gc* memberAttributes = info->GetCustomAttributes(__typeof(EntryPointAttribute), false);
0
1546
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 execute button2's click event. This works great when i know the name of the method that i want to invoke. I do so by doing this: Dim AssemblyPointer As Reflection.Assembly
2
2050
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
11188
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
1472
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 folder browse dialogue with a root other than those specified in Environment::SpecialFolders::. and I'm hoping that I would be able to specify network as the root and the defaultpath as the usersdomain much like it is done on mstsc.exe (RDT) Only...
5
4295
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 delegate: public class DelegateEx {
0
1694
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
2927
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 TestClass { public int i = 0; public int IValue
0
8473
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.