473,625 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When NOT to Reflection

Hello,

I found a reply by Peter Huang to a previous post quite valuable with regard
to referencing controls on a form by name using reflection. It made me
wonder when I would not use Reflection for this task (or any other similar
task). So, I thought I'd ask the question ... when is Reflection not an
appropriate solution (especially with regard to getting controls by name)?

Thanks!
Jack
Nov 21 '05 #1
4 880
Jack,
So, I thought I'd ask the question ... when is Reflection not an
appropriate solution (especially with regard to getting controls by name)?


For me has this a simple answer *forever* when you don't need it. It is just
late binding.

In addition I don't see any problem to solve with it which cannot be done
better without it, with the exception maybe when you are building your own
compiler or something like that.

Cor
Nov 21 '05 #2
"jack" <ja***@systemsy nergy.com.dumpt hispart> schrieb:
I found a reply by Peter Huang to a previous post quite valuable with
regard to referencing controls on a form by name using reflection. It made
me wonder when I would not use Reflection for this task (or any other
similar task). So, I thought I'd ask the question ... when is Reflection
not an appropriate solution (especially with regard to getting controls by
name)?


Reflection will only work in this case when there is a variable referencing
the control. It won't work for controls added at runtime which do not
belong to a member variable.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Thanks for the feedback. Previously, I loaded the controls into a hash table
when the form loaded. I guess your recommendation is to go back to that
method?

Jack
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uZ******** ******@TK2MSFTN GP09.phx.gbl...
Jack,
So, I thought I'd ask the question ... when is Reflection not an
appropriate solution (especially with regard to getting controls by name)?


For me has this a simple answer *forever* when you don't need it. It is
just late binding.

In addition I don't see any problem to solve with it which cannot be done
better without it, with the exception maybe when you are building your own
compiler or something like that.

Cor

Nov 21 '05 #4
Jack,
Thanks for the feedback. Previously, I loaded the controls into a hash
table when the form loaded. I guess your recommendation is to go back to
that method?


How did you know that, I had the idea to write that already in my first
message.

Cor
Nov 21 '05 #5

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

Similar topics

0
1376
by: A. Wiebenga | last post by:
Hi all! I am a student at the Hogeschool van Arnhem en Nijmegen in Holland. I am currently involved in a research project regarding Reflection. Purpose of the research project is to document what Reflection is (I can answer this question myself), what kind of Reflection Techniques there are (.NET Reflection, Python Reflection etc. I can answer this one myself too). The main question I need to answer is related to the implementation of...
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
1984
by: Mark | last post by:
Am I out of my mind if I use Reflection everytime someone logs into our site to get and track the current Major/Minor/Build/Revision version that the person is viewing our site through? This information would then be logged to a database along with some other information about the user. Thanks in advance. Mark
5
1859
by: heddy | last post by:
I understand that reflection allows me to discover the metadata of a class at runtime (properties, methods etc). What I don't understand is where this is useful. For example: If I am the sole author of an application, I already know the metadata about my classes - I wrote them. And even if I did not - Let's say I buy a 3rd party class lib, it will be documented for me with that lib. If I am part of a dev team, the same is true - If...
3
3174
by: jmbernz | last post by:
I really need help with this one, I'm trying to set the app icon during run time. There is no problem when the app is not group together, it still have the set icon but when group together if you look at the taskbar, you saw the default icon. I'm using VB.NET, here is the code: Public Sub SetIcon(ByVal strIcon As String) Dim thisExe As System.Reflection.Assembly = _ System.Reflection.Assembly.GetExecutingAssembly()...
9
3844
by: Kuberan Naganathan | last post by:
Hello all Does anyone know of a good way to use reflection in c++? I don't mean simply using rtti or dynamic casting. I'm talking about java/c# style reflection where an actual instance of an object can be constructed through reflection and method calls can be made via the reflection apis.
15
8190
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a Delegate. My testing showed that actually it was six times faster: 0.5 seconds for 100,000 iterations versus 3.1 seconds. Can anyone explain why? Something in the way I coded it? I'd appreciate any insights. Here's the code (in a Windows Form...
1
7095
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
0
1689
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;
0
8256
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
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6118
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
5570
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
4089
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
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
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.