Using a C# Library from C++ applications

Does anyone know if it's possible, and if so how do I do it

Answer this question

Using a C# Library from C++ applications

  • ineedhelp1222

    Alternatively, enable /clr compilation and directly use the C# library using C++/CLI.

  • Robert duario

    make the C# project - a COM Component.

    for this create an interface like

    give the guid here

    [Guid("")]

    public interface iTest

    {

    bool Test();

    }

    now implement this

    give the CLSID here (within the quotes)

    [Guid(""})

    public class CTest : ITest

    {

    public bool Test(){

    //....do here

    }

    }

    in the project properties make the option for register as COM interop to yes.

    then use regasm tool for registering the dll and creating the tlb.

    regasm -1 test.dll /tlb:test.tlb

    Now in VC++

    import mscore.dll

    then import test.tlb

    that's it. Now u can use CoCreateInstance to create the object of ITest.

    Regards,

    Sudeesh


  • Using a C# Library from C++ applications