Overload resolution failed because no accessible ' is most specific for these arguments: : Not most specific
In this case, we need to use Reflection. At least, I could only find this solution. Suppose my C# assembly code looks like the following:
namespace CompTest
{
///
/// Summary description for Class1.
///
public class Class1
{
public string cameLate()
{
return "He came late";
}
public string camelAte()
{
return "Camel Ate Him";
}
}
}
We can call the function camelAte in VB.NET as follows:
Dim CSClass As New CompTest.Class1
Dim ReturnValue As Object
ReturnValue = CSClass.GetType.InvokeMember("camelAte", _
System.Reflection.BindingFlags.Instance Or _
BindingFlags.Public Or _
BindingFlags.InvokeMethod, _
Nothing, CSClass, Nothing, _
Nothing, Nothing, Nothing)
TextBox1.Text = ReturnValue
InvokeMember function used here Invokes the specified member, using the specified binding constraints and matching the specified argument list. You can find more information on MSDN.
To pass parameters, create an array of Object. Insert parameters required to call the function in the array. Pass the array as a parameter in the InvokeMethod function.
No comments:
Post a Comment