472,958 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

.Net COM Server Interop

Hi everybody,

I'm working on exposing a .Net (C#) COM Server. Manage Code is exposting an interface with two methods. These methods take an IN/OUT Struct as parameter. Requirement is that the unmanaged client (C++) will initialize the struct fields with some values and these struct values can be modified or reallocated by Managed COM Server.
Struct look something like this on the managed side:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MyStruct
string s1; //tlb maps to LPWSTR s1]
string[] arrayS2 //tlb maps to SAFEARRAY* arrayS2
byte[] arrayByte //tlb maps to SAFEARRAY* arrayByte
Interface is defined as:
public interface MyInterface
int MyMethod1([In, Out] ref MyStruct myStruct);

Unamanged C++ client will be allocating the MyStruct on heap, give some heap allocation using CoTaskMemAlloc and values to s1, arrayS2 and arrayByte. Manged Server will read these values and can potentially reallocated all the fields of the myStruct.

My understanding is that the Interop Marshall (in the above scenario) will fcopy the struct and all its fields to new Struct and free the fields (which are allocated by CoMemTaskAlloc) and pass it to ManagedCode -- ManagedCode then play with the struct and its field as needed and reallocated if required. Now while returning the Interop marshall will (using CoMemTaskAlloc) copy all the fields of the Struct back to myStruct and pass to the unmanaged client. Its unmanaged client's responsibility to free the fields of myStruct once it is done with the structure.

1> Is my understanding correct?
2> Is there a better way to achieve the above [again re-emphasising the requirement: umanaged client need to pass a struct to managed COM server with fields initialized AND managed server need to return the Struct with its fields reallocated/reinitialized.

Thanks for any help/suggestion,
Apr 3 '08 #1
0 1120

Sign in to post your reply or Sign up for a free account.

Similar topics

by: David Dolheguy | last post by:
I am in desperate need to get help in answering some questions in regards to building a DCOM Server using C#. I need to create a DCOM server using C#.NET, I realise that you first need to create...
by: Kevin | last post by:
Is it possible to develop an Active Document Full Server or a Container application using C#? Thanks, Kevin.
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for...
by: Dave A | last post by:
I am writing an ASP.NET tool that will allow the client to create their own online froms. ie the client can add tect boxes, text, drop downs,etc with absolutely no technical skill what so ever....
by: Hari Menon | last post by:
I am writing a C# client (using .NET 1.1) to a web service built on Apache Axis. The server returns an array using multirefs but the C# client does not seem to be able to recognize it. I read...
by: Kurtz | last post by:
Hi, I developed a web application that run complete (all the functions) in a server with Visual Studio .NET 2003, but not run complete in a web server with .NET framework (both versions) and...
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
by: =?Utf-8?B?c3BkMzAwMQ==?= | last post by:
I have a C++/CLI app that uses a logging control in an ATL COM Server. C++ Interop seems to work just fine to pass data from the C++/CLI app to the ATL Control but I can't seem to figure out how...
by: saketmayur | last post by:
Hi , I have write the following code to open word document on server using Microsoft.Office.Interop.Word; string DocPath = System.Configuration.ConfigurationManager.AppSettings; ...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.