InvalidOperationException when calling a generic method on an instance
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
Hi All, It seems that I was missing the type in the call to a generic method, myClassInstance.MyMethod[type]() seem to work. Sorry for my impatience. 2011/1/25 Oleksii Bidiuk <oleksii.bidiuk@gmail.com>
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
-- oleksii
participants (1)
-
Oleksii Bidiuk