[Python.NET] InvalidOperationException when calling a generic method on an instance

Oleksii Bidiuk oleksii.bidiuk at gmail.com
Tue Jan 25 11:39:53 CET 2011


Hi All,

does anybody have experience with getting
the InvalidOperationException exception when calling a generic method
defined like

generic <typename T>
MyClass::AnotherClass<T>^ MyClass::MyMethod()
{
...
}

When I create an instance of the MyClass and call the MyMethod() the
exception mentioned above is thrown with the following stack trace:

System.InvalidOperationException: Late bound operations cannot be performed
on types or methods for which ContainsGenericParameters is true.
   at System.Reflection.RuntimeMethodInfo.ThrowNoInvokeException()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture, Boolean
skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr
kw, MethodBase info, MethodInfo[] methodinfo) in
C:\...\pythonnet\src\runtime\methodbinder.cs:line 356

The MyClass is an external library which I cannot influence. Calling the
MyMethod is the only way to get data access, so I cannot simply 'avoid using
it'. Perhaps some additional wrapping is needed here? Ideas are highly
appreciated!

-- 
oleksii
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20110125/f8ddb81a/attachment.html>


More information about the PythonDotNet mailing list