2

I have a a library (.dll) of C# function()s, that I want to invoke from IronPython. An example shown here - CMD_Handshake() - is defined in a , takes no arguments, and returns a boolean...

thusly,

    public bool CMD_Handshake()
    {
        .
    .
    return (Send(out b_handshake_code));

    }

[from IronPython]

clr.AddReferenceToFileAndPath() successfully adds the .dll references.

The is successfully imported. The class is successfully imported. CMD_Handshake() is recognized as a method of the class "App" is the instantiation of the class.

HOWEVER: when I invoke the function, I receive the following error message from Python:

App.CMD_Handshake() Traceback (most recent call last): File "", line 1, in TypeError: CMD_Handshake() takes exactly 1 argument (0 given)

(I feel like I'm soooo... close.)

1
  • What is the name of the class where you declared CMD_Handshake()? Is it App or is the instance of the class called App? Commented Jun 29, 2015 at 20:25

1 Answer 1

2

The issue is that bool CMD_Handshake() is an instance method and not a static one. This means you should create an instance of App and call the method on it:

app = App()
app.CMD_Handshake()

TypeError: CMD_Handshake() takes exactly 1 argument (0 given)

This error is due to the fact that you are calling an instance method as a static method and thus it expects an instance of App as its first argument.

Sign up to request clarification or add additional context in comments.

1 Comment

I apologize for taking so long to respond... in fact, this was precisely the case. I instantiated app = App(), and app.CMD_Handshake() return my boolean. Thanks, and I owe you a big coffee...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.