none
call class library RRS feed

  • Question

  • i want to call c# class library from c++ code in .net 2003.

    please provide me small sample to do it .

    Tuesday, November 6, 2012 8:30 AM

Answers

  • Hello bmvmb,

    1. The only way to accomplish this is via COM interop where a C# class is exposed as a COM coclass and instantiated in C++ code as a COM object.

    2. The C# class methods are called in C++ via COM interface methods.

    3. The following link may be helpful to you (example code included) :

    Creating a COM Server Using C#.

    https://limbioliong.wordpress.com/2011/08/30/creating-a-com-server-using-c/

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    Tuesday, November 6, 2012 8:34 AM

All replies

  • Hello bmvmb,

    1. The only way to accomplish this is via COM interop where a C# class is exposed as a COM coclass and instantiated in C++ code as a COM object.

    2. The C# class methods are called in C++ via COM interface methods.

    3. The following link may be helpful to you (example code included) :

    Creating a COM Server Using C#.

    https://limbioliong.wordpress.com/2011/08/30/creating-a-com-server-using-c/

    - Bio.


    Please visit my blog : http://limbioliong.wordpress.com/

    Tuesday, November 6, 2012 8:34 AM
  • i am working in .net framework 2003 .

    I want to call c# class library from c++ exe Application.

    i am new in this field so please guide me.

    Wednesday, November 7, 2012 4:14 AM
  • In windows, the dlls should be compatible between the Net Library and C++ provided they were compiled using the size operting system (16 bit, 32 bit, 64 bit).  So I would compile the C# code and then include the library (dll) in your C++ build instructions.  You would also have to create a C++ header file for all the functions you are using in the C# library.

    jdweng

    Wednesday, November 7, 2012 5:55 AM
  • please provide me a small sample to do it.
    Thursday, November 8, 2012 3:55 AM
  • the best place to start is the header files in the Net Library.  I don't have C++ installed on the computer I'm working on, but can give you the path tomorrow if you need it.

    jdweng

    Thursday, November 8, 2012 5:37 AM