Initialize the unmanged COM component in C#



  • Hello guys,

    i am trying to use a COM library, which is written in VB, in my C# application. What i did are:

    1. Add Reference: add the .dll file
    2. Initialize the COM components with
    [DllImport("ole32.dll")]
    static extern int CoInitialize(IntPtr pvReserved);

    and then call 'int hr = CoInitialize((System.IntPtr)null);'

    BUT, the return value of hr is always 1, that means the initialization is failure. WHO CAN HELP ME OUT OF THIS?

    Thanks in advance.

    willy



  • Hi, normally you should not be required to initialize the library yourself. .NET creates a wrapper for you to handle the COM interaction.



  • Konrad Rudolph schrieb:

    Hi, normally you should not be required to initialize the library yourself. .NET creates a wrapper for you to handle the COM interaction.

    Thank u for ur reply.
    as u said, it is not necessary to initialize the COM library. My program can interoperate with the unmanged COM component without intialization. 😃


Log in to reply