I am almost at the end of my mind and I hope that all of you will help me figure this out. I am running Anaconda Python 3.5 64 bit and compiled the anaconda Python.NET package to add .NET features for Python. I imported a DLL sent to me by someone, and here is what my code looks like:
from __future__ import (
unicode_literals,
print_function,
division,
absolute_import
)
import clr
from System import String, Char, Int32
clr.setPreload(True)
clr.AddReference('System.Windows.Forms')
clr.AddReference(
"C:\\Program Files\\XYZ\\TTE.dll"
)
import TTE
from System.Windows.Forms import Form, Application, Button
import System
tt = TTE.TT()
form = Form()
cdbp = String('C:\\')
sdbp = String('C:\\')
mdbp = String('C:\\')
tt.Initialize(cdbp, sdbp, mdbp, form)
'''
tt.Initialize.Overloads[
System.String, System.String, System.String, System.Windows.Forms.Form](
cdbp, sdbp, mdbp, form
)
'''
When I run the Initialize function, I get the following exception:
Traceback (most recent call last):
File "C:/Users/as/All/Code/try1.py", line 257, in <module>
tt.Initialize(cdbp, sdbp, mdbp, form)
System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'TTE.TT+ResultEnum&'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
I am new to .NET and tried a search on Google and looked at all the stack overflow messages related to Python.NET, but I did not find the information I'm looking for. Another curious thing: the same DLL works when used in VB and fails when used in python. Why would that be?
, , Python.NET , () Initialize, Overloads ( ), :
Traceback (most recent call last):
File "C:/Users/as/All/Code/try1.py", line 261, in <module>
System.Windows.Forms.Form](cdbp, sdbp,
TypeError: No match found for signature
Int32 Initialize(System.String ByRef, System.String ByRef, System.String ByRef, System.Windows.Forms.Form, ResultEnum ByRef, ResultEnum ByRef, ResultEnum ByRef)
Int32 Initialize(System.Collections.Specialized.StringCollection ByRef, System.String ByRef, System.String ByRef, System.Windows.Forms.Form, ResultEnum ByRef, ResultEnum ByRef, ResultEnum ByRef)
Int32 Initialize(System.Collections.Generic.List`1[System.String] ByRef, System.String ByRef, System.String ByRef, System.Windows.Forms.Form, ResultEnum ByRef, ResultEnum ByRef, ResultEnum ByRef)
, Overload , VB Initialize targeting ResultEnum , Python .
, ?