@san1907 -
Option Explicit
-
Private m_Street As String
-
-
Public Function GetNameBlank() As String
-
GetNameBlank = "Hello World"
-
End Function
-
-
Public Function GetName(SomeString As String) As String
-
GetName = SomeString
-
End Function
-
-
Public Property Let Street(ByVal strNewStreet As String)
-
If Len(strNewStreet) = 0 Then Err.Raise 5
-
m_Street = strNewStreet
-
End Property
-
-
Public Property Get Street() As String
-
Street = m_Street
-
End Property
-
---------------------------------------------------------------------------
this is the VB6.0 dll, name is : project5.dll
convert it in wrapper using regsvr32, sn -k and tlbimp, name is : project5wrapper .dll
---------------------------------------------------------------------------
then i wish to call this wrapper dynamically in .net in this way :
-------------------------------------------------------------------------
-
Assembly assembly = Assembly.LoadFrom(@"D:\Work\ex\project5stepwrapper .dll");
-
foreach (Type Cls in assembly.GetTypes())
-
{
-
if (Cls.IsInterface)
-
continue;
-
object instance = Activator.CreateInstance(Cls);
-
foreach (MethodInfo Method in Cls.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
-
if (String.Compare(Method.Name, "GetName", false) == 0)
-
{
-
var parameters = new List<object>();
-
foreach (ParameterInfo pi1 in ((MethodInfo)Method).GetParameters())
-
{
-
if (pi1.ParameterType == typeof(string))
-
parameters.Add("test");
-
}
-
object returnValue = Method.Invoke(instance, parameters.Count == 0 ? null : parameters.ToArray());
-
-
if (returnValue != null)
-
Trace.Assert(true, returnValue.ToString());
-
}
-
}
------------------------------------------------------------------------------------
function GetNameBlank() and property Street are successfully invoke because they have no parameters
but when invoking GetName(), an error messege is coming
Object of type 'System.Reflect ion.RuntimePara meterInfo' cannot be converted to type 'System.String& '
-----------------------------------------------------------------------------------
if it solved then try to call this .net class library in vb6.0
--------------------------------------------------------------------------------------