[IronPython] Why Method call is not working?

Curt Hagenlocher curt at hagenlocher.org
Thu Sep 16 14:37:43 CEST 2004


"senthilkumar" <senthilkumar.chockalingam at kla-tencor.com> writes:

> I'm trying to call a method of a .Net component, but it allways
> throws error.
> 
> here is the code i executed
> 1. o = sampleGAC.TestClass //(Namespace.classname)//works fine
> 2. o.ReturnTest() // not working, allways produce error as follws

You are not creating o as an object of type sampleGAC.TestClass.
You are setting o equal to a reference to the class object.  The
class object does not have a member called ReturnTest() -- though
if ReturnTest were static, this would work.

> I also tried with .new System Components, i created a instance of
> datetime and tries to access the method ToLongTimeString(), as
> 
> o = System.DateTime //works fine
> o.ToLongTimeString  //Error

Same issue.  "o = System.DateTime(2004, 9, 16)" will work, because
you will then actually invoke the constructor. 

--
Curt Hagenlocher
curt at hagenlocher.org



More information about the Ironpython-users mailing list