Python for C # StongBox [Single]
I used IronPython to add a c # dll reference. I am trying to use a method in a DLL that requires a type argument:
out float tempValue
When I pass the python float object to the method, I get the following traceback:
Traceback (most recent call last):
File "MeasurementComputing.py", line 20, in <module>
TypeError: expected StrongBox[Single], got float
My questions:
- What is StrongBox [Single]
- How can I create such an object in python to go to C # method.
+3
source to share
1 answer
To have the correct target for the out parameter, you need to explicitly create a clr reference ( StrongBox serves as that references / values ββwrapper) in IronPython, since the out keyword on the caller side (in C # for example) is missing, which will allow you to do this ...
It might look like this:
import clr
import System
tempValue = clr.Reference[System.Single]()
Directly instantiating the StrongBox should work as well.
Remember that you can also use methods that only have parameters, without passing anything other than getting a tuple, as described here .
+1
source to share