|
|
 |
RE: FN-FORUM: .NET calling unknown functions from code
date posted 17th January 2005 22:55
Interesting, CallByName is not available in C#, although apparently it may
be available by adding a reference to the visual basic namespace!? I wonder
what other VB goodies I can get at that way?
-----Original Message-----
From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of Andy
Macnaughton-Jones
Sent: 17 January 2005 23:14
To: FN-FORUM / [EMAIL REMOVED]
Subject: RE: FN-FORUM: .NET calling unknown functions from code
Cheers, I'll have a look. The thing I was actually trying to remember
was "CallByName" which lets you call functions by knowing the name of
the function as a string.
-----Original Message-----
From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of
[EMAIL REMOVED]
Sent: Monday, January 17, 2005 11:04 PM
To: Andy Macnaughton-Jones
Subject: RE: FN-FORUM: .NET calling unknown functions from code
Andy,
As far as I know because .net is inherently strongly typed, you can't
call functions in that way. The only way I know of is to use the
System.Reflection namespace to examine a target object and use one of
the Invoke methods to call it's methods dynamically. I've found one
article that may be of use:
http://builder.com.com/5100-6373_14-1050654.html
HTH
Danny
-----Original Message-----
From: [EMAIL REMOVED] [EMAIL REMOVED] On Behalf Of Andy
Macnaughton-Jones
Sent: 17 January 2005 20:16
To: FN-FORUM / [EMAIL REMOVED]
Subject: FN-FORUM: .NET calling unknown functions from code
Hi,
I'm trying to build some code whereby the generates ASP.NET pages will
control the code / functions that are called.
Because the pages are generated by xslt, I don't want to limit the
functions that may or may not be called.
I can't remember how in VB.NET to call a function by a soft-coded name.
E.g.
Dim X as string
X = fnMyFunction("123")
Is fine
But how do I do;
Dim X as string
Dim Y as string
Y = "fnMyFunction"
X = Y("123")
If that makes sense.
Otherwise I'm going to have to hard code all of the functions that I may
or may not call. This is for some shared code and I don't want to have
to limit what I'm doing at this point.
The other option I had was to create an standard interface and create
objects that way, but using createobject("object.class") doesn't work
for me in .NET, so I'm a bit buggered.
Suggestions on a plate please ;-)
Cheers
Andy
and freelance jobs
--
Freelancers, contractors earn more with Prosperity4 Call 0870 870 4414
or visit www.prosperity4.com and benefit from Inland Revenue approved
expenses today.
To advertise here: http://www.freelancers.net/advertising.html
--
Freelancers, contractors earn more with Prosperity4
Call 0870 870 4414 or visit www.prosperity4.com
and benefit from Inland Revenue approved expenses today.
To advertise here: http://www.freelancers.net/advertising.html
Unsub: http://www.freelancers.net/rm.php?g~418049DC507F05D668
To Post a New Message: [EMAIL REMOVED]
Forum Homepage: http://www.freelancers.net/forum.php
http://www.freelancers.net - freelancers and freelance jobs
|
 |
|