Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET to C# late binding problem

Status
Not open for further replies.

JL327

Technical User
Oct 30, 2003
2
US
In VB.Net this late binding works fine


Dim Version As Integer
Dim Revision As Integer
Dim Wnum As Integer
Dim o As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim h As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim l As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim c As System.Array = System.Array.CreateInstance(GetType(Single), 1)
Dim Vol As System.Array = System.Array.CreateInstance(GetType(Int32), 1)
Dim Dates As System.Array = System.Array.CreateInstance(GetType(Int32), 1)



t = CreateObject("TC2000Dev.cTC2000")

Wnum = 1000

Revision = t.GetRevision
Label1.Text() = Revision

t.GetPrices(Wnum, o, h, l, c, Vol, Dates, 100)

Label2.Text() = c(1)




When it is converted to C# late binding, the GetRevision method works but the GetPrices does not

GetRevision only is suppose to return an Int32, but GetPrices is supposed to return multiple System.Arrays



int WNum = 1000;

System.Array _open = new System.Single[1];
System.Array _high = new System.Single[1];
System.Array _low = new System.Single[1];
System.Array _close = new System.Single[1];
System.Array _vol = new System.Int32[1];
System.Array _date = new System.Int32[1];
object[] d = {WNum, _open, _high, _low, _close, _vol, _date, day};


Type myType = Type.GetTypeFromProgID("TC2000Dev.cTC2000");
object myObject = Activator.CreateInstance(myType);

Int32 Revision = (Int32) myType.InvokeMember("GetRevision",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
myObject,
new object[]{});



label1.Text = Revision.ToString();


d = (object[]) myType.InvokeMember("GetPrices",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
myObject,
new object[]{WNum, _open, _high, _low, _close, _vol, _date, 100});


How does the InvokeMember need to change to allow the GetPrices to work?

WNum and 100 are the input params, and _open, _high, _low, _close, _vol, _date are system arrays that

are returned

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top