trouble getting ref object parameters while calling COM object with C#

  • Thread starter Thread starter rocketfire97
  • Start date Start date
R

rocketfire97

I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.

I've tried the same call using VB.NET and can get data back. How would
I implement the following in C#

This is the method I am calling, which populates ref paramters with
results.

Sub Check_Customer(ByVal Customer As String, Optional ByRef oParam1 As
Object = Nothing, Optional ByRef oParam2 As Object = Nothing, Optional
ByRef oParam3 As Object = Nothing, Optional ByRef oParam4 As Object =
Nothing, Optional ByRef Return As Object = Nothing)

Here is the VB.net code, which calls the function passing

Dim customer = "123456", oParam1 = Nothing, oParam2 = Nothing, oParam3
= Nothing, oParam4 = Nothing, oReturnBlock = Nothing

comObject.Check_Customer(customer, oParam1, oParam2, oParam3, oParam4,
oReturnBlock)

Dim myDA As System.Data.OleDb.OleDbDataAdapter = New
System.Data.OleDb.OleDbDataAdapter
Dim myDS1 As DataSet = New DataSet
Dim myDS2 As DataSet = New DataSet
myDA.Fill(myDS1, oParam1, "CustomerDetails")
myDA.Fill(myDS2, oParam2, "CustomerNotes")


Any help would be greatly appreciated.
 
string a=null,b=null;
aaaa(ref a, ref b);
u should use ref key world when passing parrameter to com function and
assing null before passing it.
 
string a=null,b=null;
aaaa(ref a, ref b);
u should use ref key world when passing parrameter to com function and
assing null before passing it.

There is no problem getting string values passed by reference, the
problem is with parameters of type Object passed by reference. The COM
component returns recordsets in the ref objects and vb.net handles
this automatically so values can be accessed eg. oParam1("Name") after
the call contains data or even filling a dataset. However with C# I
can't get to the data within the Object.

I have tried the InvokeMember call using the BindingFlags.GetProperty
and BindingFlags.GetField but still unable to get the recordset.
 
Back
Top