Hi,

I found my problem - thanks for the help Dino. CClassName was not public. Now 
it works fine.

Greetings,
Georg

From: [email protected] 
[mailto:[email protected]] On Behalf Of Dino Viehland
Sent: Mittwoch, 26. August 2009 18:46
To: Discussion of IronPython
Subject: Re: [IronPython] Call methods from Python-Script

Is CClassName a public type?  It'll need to both have public members and also 
be public its self.

If that's not the problem I'm having trouble understanding exactly what's going 
on.  Is "return class.doSomething(parameter)" supposedly Python code?  Or are 
you doing this from C#?  "class" is a keyword in Python so I don't see how it's 
Python code.

From: [email protected] 
[mailto:[email protected]] On Behalf Of Eichhorn, Georg
Sent: Tuesday, August 25, 2009 11:00 PM
To: [email protected]
Subject: [IronPython] Call methods from Python-Script

Hi,

I have implemented some piece of code that should execute a python-script. In 
this script I want to call a c#-function.
First, I Generate a module (context to work in):

 _scriptRuntime.Start(true);
 _scriptRuntime.ScriptScope.SetVariable("class", this); ('this' is CClassName')

Then I get the class:

PythonType pType = _scriptRuntime.ScriptScope.GetVariable("CClassName") as 
PythonType;

Create an instance of the object

_Class = _scriptRuntime.ScriptScope.Engine.Operations.CreateInstance(pType, new 
object[] { });

[...] (do some other tings)

>From the python script, I want to call the function:

return class.doSomething(parameter)

The code throws an exception:

'CClassName' object has no attribute 'doSomething'.

What am I making wrong? CClassName has a public method doSomething()

Thanks for U're help.

Greetings
Georg Eichhorn

________________________________
The information contained in this message may be confidential and legally 
protected under applicable law. The message is intended solely for the 
addressee(s). If you are not the intended recipient, you are hereby notified 
that any use, forwarding, dissemination, or reproduction of this message is 
strictly prohibited and may be unlawful. If you are not the intended recipient, 
please contact the sender by return e-mail and destroy all copies of the 
original message.

________________________________
The information contained in this message may be confidential and legally 
protected under applicable law. The message is intended solely for the 
addressee(s). If you are not the intended recipient, you are hereby notified 
that any use, forwarding, dissemination, or reproduction of this message is 
strictly prohibited and may be unlawful. If you are not the intended recipient, 
please contact the sender by return e-mail and destroy all copies of the 
original message.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to