PC Review


Reply
Thread Tools Rate Thread

CCW COM and Parameters

 
 
James
Guest
Posts: n/a
 
      26th Apr 2009
I am writing a component in C# which is a COM Callable Wrapper. Some of the
methods pass structs across COM. My question is, how does COM pass
parameters such as structs? I know that C# passes structs by value. The
struct data being passed from the Win32 client is never going to be modified,
so I would like to prevent making a copy of the struct across the COM
barrier. In C# The struct is being passed by reference (added ref keyword to
parameter) since I don't want to make a copy there either. I'm going through
enough layers already and I would prefer not to be making multiple copies of
a struct every time it is passed as a parameter.

Thanks!

--
James

 
Reply With Quote
 
 
 
 
Pavel Minaev
Guest
Posts: n/a
 
      26th Apr 2009
On Apr 25, 6:18*pm, James <baodurasp...@community.nospam> wrote:
> I am writing a component in C# which is a COM Callable Wrapper. *Some of the
> methods pass structs across COM. *My question is, how does COM pass
> parameters such as structs?


It's up to you, depending on how you define the interface.

> *I know that C# passes structs by value. *The
> struct data being passed from the Win32 client is never going to be modified,
> so I would like to prevent making a copy of the struct across the COM
> barrier. *In C# The struct is being passed by reference (added ref keyword to
> parameter) since I don't want to make a copy there either. *I'm going through
> enough layers already and I would prefer not to be making multiple copiesof
> a struct every time it is passed as a parameter.


If your C# code defines the argument as "ref" or "out", there should
be no copy involved during marshaling, unless the struct itself has
some fields that require special marshaling (e.g. strings, or arrays
declared without "fixed" keyword).
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpectedly prompted for parameters using parameters of form EdA Microsoft Access Forms 0 30th Apr 2008 09:53 PM
Help Needed. Update with parameters error - No value given for one or more parameters. Hexman Microsoft VB .NET 2 10th Aug 2006 07:46 PM
How can i make a help file with parameters as the menus parameters =?Utf-8?B?S2ltb24=?= Microsoft Access 0 21st Oct 2005 05:56 PM
Passing output parameters to SQL Server stored procedures through an SqlCommand object's Parameters collection Mark Rae Microsoft ADO .NET 8 26th Sep 2005 03:28 PM
Why is 2098 the maximum number of parameters in SqlCommand.Parameters Paul Clark Microsoft ADO .NET 3 24th Aug 2003 06:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:25 PM.