InvalidOperationException when calling a generic method on an instance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

InvalidOperationException when calling a generic method on an instance

Oleksii Bidiuk
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

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: InvalidOperationException when calling a generic method on an instance

Oleksii Bidiuk
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 <[hidden email]>
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

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet