Click here to Skip to main content
15,878,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a dll in vb6 which i use to call in c#(vs2008) like this

add reference
C#
PrjMainO.ClsMainClass ClsSAGMainO = new PrjMainO.ClsMainClass();

object myobj = new object();
bool x = false;
string strvalue= ClsSAGMainO.InitProdNew("myAppname",  "Logger.Log",  2014, ref str, ref x);


Now i want to call the function in this manner
C#
object objrval = new object();
           objrval = 0;

           object[] oparam = new object[] { "myAppname",  "Logger.Log",  2014 };
           object objJRO = Activator.CreateInstance(Type.GetTypeFromProgID("PrjMainO.ClsMainClass"));
           objrval= objJRO.GetType().InvokeMember("InitProdNew",
               System.Reflection.BindingFlags.InvokeMethod,
               null,
               objJRO,
              oparam);
           string strvalue= Convert.ToString(objrval);


my problem is how can i add reference string and bool arugement in my object array oparam
Posted
Updated 24-Jan-14 0:18am
v2

1 solution

// Create an array containing the arguments. object[] args = {"Argument 1", "Argument 2", "Argument 3" };

// Initialize a ParameterModifier with the number of parameters. ParameterModifier p = new ParameterModifier(3);

// Pass the first and third parameters by reference. p[0] = true; p[2] = true;

// The ParameterModifier must be passed as the single element // of an array. ParameterModifier[] mods = { p };

// Invoke the method late bound. obj.GetType().InvokeMember(" MethodName", BindingFlags.InvokeMethod, null, obj, args, mods, null, null);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900