HighTechTalks DotNet Forums  

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

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss trouble getting ref object parameters while calling COM object with C# in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
rocketfire97@gmail.com
 
Posts: n/a

Default trouble getting ref object parameters while calling COM object with C# - 10-28-2007 , 09:36 PM






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.


Reply With Quote
  #2  
Old   
Som Nath Shukla
 
Posts: n/a

Default RE: trouble getting ref object parameters while calling COM object wit - 10-29-2007 , 01:38 AM






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.



"rocketfire97 (AT) gmail (DOT) com" wrote:

Quote:
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.



Reply With Quote
  #3  
Old   
rocketfire97@gmail.com
 
Posts: n/a

Default Re: trouble getting ref object parameters while calling COM object wit - 10-29-2007 , 02:21 PM



On Oct 29, 1:38 am, Som Nath Shukla
<SomNathShu... (AT) discussions (DOT) microsoft.com> wrote:
Quote:
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.

"rocketfir... (AT) gmail (DOT) com" wrote:
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.
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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.