Need some help about Late-Binding !!!!

Hi,

i wrote this code in order to create an instance from a .NET class library that act like Plug-In... But i have some trouble with the late-binding :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oObj As System.Runtime.Remoting.ObjectHandle
Dim MyObj As iClsBind

oObj = Activator.CreateInstanceFrom("D:\vsnetTest\clsBind\bin\clsBind.dll", "clsBind.clsBind")
MyObj = CType(oObj.Unwrap(), iClsBind)
MessageBox.Show(MyObj.CalcIt(23, 23))
oObj = Nothing
End Sub
Public Interface iClsBind
Function CalcIt(ByVal FirstVal As Short, ByVal secVal As Short) As Int32
End Interface


The createinstance method works fine, but when I want to convert the objecthandle to the correct type in this case : using IclsBind (interface) and I get an "Invalid cast" error !

Any ideas ???

Thanks,

Ray



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories