I have build a simple user control that implements an interface.
In my page, I use the LoadControl method to load the control dynamically :
dim myControl as IMyInterface
myControl = CType(Page.LoadControl(<path>\MyControl.ascx), IMyInterface)
The control is loaded without a problem and I could now execute the MyFunction method (as defined in the interface, see below) of the control like this :
myControl.MyFunction()
All this is no problem.
But I created this test control to test the InvokeMember method. Instead of calling MyFunction directly, I want to call it using the InvokeMember method :
myControl.GetType().InvokeMember("MyFunction", BindingFlags.InvokeMethod, Nothing, myControl, Nothing)
This always returns : "method not found". How come ? What am I doing wrong here ?
Thx,
Dave
.ascx file
<%
@ Control Language="vb" AutoEventWireup="false" CodeFile="MyControl.ascx.vb" Inherits="MyControl" %>
.ascx.vb file
Partial
Public Class MyControl
Inherits System.Web.UI.UserControl
Implements IMyInterface
Public Function MyFunction() As Boolean Implements IMyInterface.MyFunction
return true
End Function
End Class
interface file
Public Interface IMyInterface
Function MyFunction()
End Function
End Interface