//
archives

interop marshaler

This tag is associated with 17 posts

Tip for Managed Applications that use COM objects – Type Libraries are Used at Runtime.

1. Introduction. 1.1 My last article Tip for Creating a COM Server Using C# – Apartment Marshaling and the Type Library centred on the fact that for managed COM servers used by an unmanaged client app, its REGASM.EXE generated type library is not used at runtime. 1.2 As mentioned in that article, the reasons managed COM … Continue reading

Tip for Creating a COM Server Using C# – Apartment Marshaling and the Type Library.

1. Introduction. 1.1 I had earlier published Creating a COM Server Using C#. The aim of that article was to expound on the basic coding requirements for creating a COM server using the C# language. 1.2 This write-up is one of several follow-up articles that are intended to provide additional supplementary tips, techniques and knowledge … Continue reading

Passing Managed Structures With Strings To Unmanaged Code Part 3

1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (which contains strings) to unmanaged code. The structure was passed as an “in” (by-value) parameter, i.e. the structure was passed to the unmanaged code as a read-only parameter. 1.2 Then in part 2, we studied the techniques for receiving … Continue reading

Passing Managed Structures With Strings To Unmanaged Code Part 2

1. Introduction. 1.1 In part 1 of this series of blogs we studied how to pass a managed structure (which contains strings) to unmanaged code. The structure was passed as an “in” (by-value) parameter, i.e. the structure was passed to the unmanaged code as a read-only parameter. 1.2 Here in part 2, we shall explore the … Continue reading

Passing a Pointer to a Structure from C# to C++ Part 1.

1. Introduction. 1.1 Unmanaged APIs, especially those written in C++, sometimes require pointers to structures to be passed as parameters. 1.2 This may be a breeze for C++ developers but for C# programmers, careful attention must be paid to the contents of the structures. 1.3 This is due mainly to the fact that a managed structure needs … Continue reading

Specifying Arrays in UDTs

1. Introduction. 1.1 Although COM User-Defined Types (UDTs) commonly use BSTRs to hold strings (i.e. character arrays) and SAFEARRAYs to hold arrays of other types, it is possible to define character arrays and arrays of other types inside a UDT. 1.2 This blog will demonstrate the use of arrays inside a UDT with an emphasis … Continue reading

Specifying SAFEARRAY parameters with COleDispatchDriver::InvokeHelper()

1. Introduction. 1.1 Recently, someone from the MSDN forum requested advise on a problem he faced while attempting to call a C# method (exposed as a COM method) from an unmanaged MFC application. 1.2 The C# method takes an array of integers by reference, e.g. : bool SetArray([In][Out] ref Int32[] integer_array); 1.3 His C# class is … Continue reading

Interoping COM Structures.

1. Introduction. 1.1 COM structures, or User-Defined Types (UDTs) are very useful constructs. Their interoperability in managed code, however, is not perfect and there are situations in which their use is not possible. 1.2 This blog examines various scenarios in which UDTs are used between COM and managed code (specifically C#). We will also analyze the success … Continue reading

Marshaling a SAFEARRAY of Managed Structures by COM Interop Part 2

1. Introduction. 1.1 In part 1 of this series of blogs, we studied how to pass a SAFEARRAY of UDTs (which originate from managed code) to an unmanaged client. 1.2 In this part 2, we shall be looking at how to pass a SAFEARRAY of UDTs from an unmanaged COM client application to a managed COM server. 2. … Continue reading

Marshaling a SAFEARRAY of Managed Structures by COM Interop Part 1

1. Introduction. 1.1 There are two basic ways to pass an array of managed structures to unmanaged code. These include : By C-style array. By SAFEARRAY. 1.2 In this series of blogs I shall expound on the use of SAFEARRAYs to pass an array of managed structures to unmanaged code. 1.3 In this part 1, I shall provide background information … Continue reading