COM client in C++ AND COM server in C#

Below is the code for COM Client in C++, which calls COM server written in C# below. I have copied an interface.

This is more of a C# question. But I am guessing most of you would know about it.

COM server interface in C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Guid("4df99b70-e148-4432-b004-4c9eeb535a5e")]
    public interface IFunctionDiscovery
    {
        unsafe void GetInstanceCollection(string pszCategory, string pszSubCategory, int fIncludeAllSubCategories, CFunctionInstanceCollection** ppCFunctionInstanceCollection);

    };
    public class SampleClass : IFunctionDiscovery
    {
        public unsafe void GetInstanceCollection(string pszCategory, string pszSubCategory, int fIncludeAllSubCategories, CFunctionInstanceCollection** ppCFunctionInstanceCollection)
        {
            System.Console.WriteLine("GetInstanceCollection() called...");
            CFunctionInstanceCollection* ppFIC = new CFunctionInstanceCollection();
            ppCFunctionInstanceCollection = &ppFIC;
        }
    }

Compiling the C# code, gives an error:

Program.cs(19,21): error CS0208: Cannot take the address of, get the size of, or
declare a pointer to a managed type

Compiler is pointing at the last argument in GetInstanceCollection method of COM server. Does anyone know how to fix the problem?

Thanks!
Last edited on
Topic archived. No new replies allowed.