3

I use pythonnet not ironpython.

There is a function like this:

test(ref string p1,out string p2)

How can I call test in python 3.6?

import clr
import sys
import System
sys.path.append(r'd:\dll')  
clr.FindAssembly('communication.dll')  
from  communication import *  
dll=IEC62056()
dll.test(----------)
4
  • you can check similar discussion here Commented Mar 7, 2018 at 7:38
  • hmm not a best solution but why not make a console program to wrap your dll and then call console program from python ? Commented Mar 7, 2018 at 7:39
  • @Rahul Agarwal this page is iropython not pythonnet pythonnet.github.io Commented Mar 7, 2018 at 8:32
  • @ Agent_Orange I am sorry, i can't understand, can you show me examples? Commented Mar 7, 2018 at 8:35

2 Answers 2

1

I can't test the code without communication.dll, so please check if the following code is working for you:

import clr
import sys
sys.path.append("D:\\dll") # path to dll
clr.AddReference("communication") # add reference to communication.dll
from  communication import test

ref_string_p1 = "----------"
out_string_p2 = test(ref_string_p1)
print(out_string_p2)
Sign up to request clarification or add additional context in comments.

Comments

0

you can feed ref as a regular argument, and feed out arbitrarily. pythonnet will return them positionally as tuple.

assume void test(ref string p1,out string p2) in c#, you get p1, p2 = test(p1, None) in python

1 Comment

The documentation about ref parameters is quite clear: pythonnet.github.io/pythonnet/….

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.