473,396 Members | 1,725 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,396 software developers and data experts.

Reflexion technique help !

Hi people.

I am trying to replace the old CallByName function of VB6 with those of .NET
I have a Class with a String Property and a Method with 3 arguments which
returns a DateValue.
How do I use reflexion (with Invoke as I as told) to pass values the
property and call the method on that class.
Basically my class names would be stored as string a config file and, I
would dynamically call them.

My Class has the following member:
Public property TagValue () As String
Public Function Find(ByVal StartPosition As Int32, ByVal TagName As String,
ByVal MySource As DataTable) As Int16

A short example based on that definition would be of great help.

Thanks,
Jean-Yves
Nov 21 '05 #1
2 1629
You can still use CallByName in VB.NET. Any reason why you wouldn't want to
use that? What you would need is to create an instance of the object from
the class name. Use Activator.CreateInstance to create an instance of the
object. Also, you'll need to use the Type.GetType method to get the type of
the object from the class name. Note that you will have to provide the fully
qualified class name - including namespace and assembly name if the class is
in another assembly. Look up the documentation for Type.GetType to get it to
work correctly in your case. If the class is the same one as the executing
assembly, you can do this for your class (say TestClass which is within
namespace TestNameSpace):

Dim ty As Type = Type.GetType("TestNameSpace.TestClass")

Dim obj As Object = Activator.CreateInstance(ty)

CallByName(obj, "TagValue", CallType.Set, "Tag Value is Set")

Dim Tag As String = _
CStr(CallByName(obj, "TagValue", CallType.Get))

Dim Return As Int16 = _
CallByName(obj, "Find", CallType.Method, _
1, "Tag Name", myDataTable)
hope that helps..
Imran.

"Jean-Yves" <je******@gmx.net> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
Hi people.

I am trying to replace the old CallByName function of VB6 with those of
.NET
I have a Class with a String Property and a Method with 3 arguments which
returns a DateValue.
How do I use reflexion (with Invoke as I as told) to pass values the
property and call the method on that class.
Basically my class names would be stored as string a config file and, I
would dynamically call them.

My Class has the following member:
Public property TagValue () As String
Public Function Find(ByVal StartPosition As Int32, ByVal TagName As
String, ByVal MySource As DataTable) As Int16

A short example based on that definition would be of great help.

Thanks,
Jean-Yves

Nov 21 '05 #2
"Jean-Yves" <je******@gmx.net> schrieb:
I am trying to replace the old CallByName function of VB6 with those of
.NET
I have a Class with a String Property and a Method with 3 arguments which
returns a DateValue.
How do I use reflexion (with Invoke as I as told) to pass values the
property and call the method on that class.
Basically my class names would be stored as string a config file and, I
would dynamically call them.


Your system date/time is wrong...

First there is no reason not to use 'CallByName'.

Calling a method by its name
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=callbyname&lang=en>

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

Nov 21 '05 #3

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

Similar topics

4
by: serge calderara | last post by:
Dear all, I need to create an instance object of a library wit the following way: obj = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap ("Mylib.dll, "PluginApp.PlugIn") This works fine...
3
by: Jack Klein | last post by:
I'm looking for opinions on a C technique I, and others, have used successfully in the past. While some people swear by, apparently others swear at it. Assume a part of a program too large to...
0
by: deathyam | last post by:
Hi, I am writing an application in Excel 97 in which the users click a button and data is saved/read to and from an Access 97 database on the LAN. I am concerned about performance because there...
1
by: Marc Falesse | last post by:
Hello, My application needs to serialize a class, which was generated with xsd.exe from a XSD. It was working .NET 1.1 and it is working with .NET 2.0 very well. Now I need my assembly to be a...
1
by: Jose M. Nobre | last post by:
Hi, Does anyone knows if through reflexion is it possible to retrieve a parameter value? I mean, having the method: void foo( int val ) { //... inspect( ); //...
18
by: xahlee | last post by:
Last year, i've posted a tutorial and commentary about Python and Perl's sort function. (http://xahlee.org/perl-python/sort_list.html) In that article, i discussed a technique known among...
3
by: pragy | last post by:
Hey, can any one help me for writing a program of naive gauss elimintaion technique? It's a technique to solve system of simultaneous linear equations using matrix. thanks
2
by: Bob Alston | last post by:
Recently I have been helping a nonprofit modify a system built in Access, that they acquired from another nonprofit. I am doing this as a volunteer. I would like your perspective on two...
1
by: Ben Bacarisse | last post by:
cri@tiac.net (Richard Harter) writes: <snip> I too was going to mention the technique until I saw Eric's reply because in your sketch you said: | we have definitions like | | struct...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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...

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.