By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

How to add a method member to a class or object in run-time?

P: n/a
In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object?
As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will
have some additional methods which have been described in
WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:

set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
This won't work in C#, because object.method needs to be resolved at
compile-time, and the method doesn't exist. Try creating a method called
"Invoke" that takes a string argument specifying the name of the "method"
you want to run. The implementation is up to you (you could dynamically
generate code using Reflection.Emit, or just have custom code to interpret
any commands).

-mike
MVP

"peter" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object?
As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will
have some additional methods which have been described in
WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:

set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?

Nov 15 '05 #2

P: n/a
Thanks a lot,you are so kind.
Your solution is useful for me.But the class,
soapclient30 in MS soap toolkit30,is implemented the
function that I expect well and truly.Would you please
take some time to analysis the soapclient30 class?
I will appreciate an early reply.

toolkit-----Original Message-----
This won't work in C#, because object.method needs to be

resolved atcompile-time, and the method doesn't exist. Try creating a method called"Invoke" that takes a string argument specifying the name of the "method"you want to run. The implementation is up to you (you could dynamicallygenerate code using Reflection.Emit, or just have custom code to interpretany commands).

-mike
MVP

"peter" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
In run-time,is there any approach to add or revise the
members,such as method or attribute ,of a class or object? As for the object of class soapclient30 in MS soap
toolkit, after it executes the mssoapinit method,it will have some additional methods which have been described in WSDL file. For an example,if a Web service provides
an "divide" method,the WSDL filename is mycalculator.wsdl:
set soapclient = CreateObject("MSSOAP.SoapClient30")
soapclient.mssoapinit "mycalculator.wsdl", "", "", ""
soapclient.divide 10,5

that is,the soapclient object has the divide method.
how to add the "divide" method for SoapClient30 class
internally?

.

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.