//
archives

COM interop

This tag is associated with 7 posts

Perform Custom Action during Registration of a Managed COM Server.

1. Introduction. 1.1 When a COM-visible managed class library is COM registered via regasm.exe, it is possible to perform various custom activities, e.g. adding additional registry keys/values. 1.2 In fact, just about anything can be performed, e.g. reading/writing data to a file, launch external processes, etc. 1.3 Then, if the class library is unregistered, reverse activities … Continue reading

RCW Internal Reference Count

1. Introduction. 1.1 The Runtime Callable Wrapper (RCW) is used to represent a COM object in the managed world. Internally a RCW contains a reference count on the COM object that it wraps. 1.2 Note that this reference count is not equivalent to the well-known COM reference count. The COM reference count is held within the … 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

Misunderstanding IDL Parameter Direction Leading to BSTR Memory Leakage.

1. Introduction. 1.1 Just yesterday a Visual C# Forum Member posed an interesting question. The post can be found here : Possible BSTR memory leak 1.2 Basically, he designed a COM class (in IDL) that takes charge of acquiring data from some source. He also defined a callback interface that is to be implemented by clients. An instance … Continue reading

Research Topic : Hidden COM Callable Wrapper.

1. Introduction. 1.1 Recently, someone from the MSDN forum presented a very interesting question. 1.2 He wrote a simple C# class which is COM exported. When he instantiated one such a managed class in an unmanaged C++ application, he noticed that there were two COM-Callable Wrappers created in the application. One for the exported C# class … Continue reading