Important: Please read the Qt Code of Conduct -

csharp with qt

  • *how to use csharp .dll in qt

  • Lifetime Qt Champion

    You mean to call a function in it ?
    or how to use ?

    It is not possible to use classes exported from it in any easy way.
    As far as i know, you must export com objects and use those in c++.

    Maybe visual studio offer some help in this area.

    You can google "csharp dll in qt" and read all the suggestions.

  • You need to compile with clr set on.

    In visual studio 2013:

    • project properties->configuration properties->general-> common language support -> /clr
    • project properties->configuration properties->C/C++->Code generation-> Enable C++ Exceptions->/EHa
    • project properties->configuration properties->C/C++->Code generation-> Runtime Library->/MD (or /MDd in debug)
      • The 3 options above can be applied even to a single .cpp file instead of the whole project, just right click on the file instead of the project
    • project properties->common properties->add new reference->drowse->browse->select the C# dll
    • use #using <MyCSharpLibrary.dll> at the top of your .cpp file
    • To write managed code you need a dialect of C++ called C++/CLI

  • @VRonin sir,
    Thank you sir,successfully added .dll file in QT but i create visual c++ project(MFC application),here display error like LNK2020 and LNK2001

  • sir ,here i have add .cs( c sharp) file or .cpp (visualc++) file.
    suppose i add .cpp file means errors are(afxmn...)

  • Lifetime Qt Champion

    @Rameshguru said in csharp with qt:

    LNK2020 and LNK2001

    Please show the whole error messages not just these numbers.
    What does this mean: "suppose i add .cpp file means errors are(afxmn...)"?

  • @jsulm sir,
    first i create visuall c++ mfc application project then add library files.
    here .cpp files there (or) .cs files are there,first i go to proerties->add exising item which file are add .cpp or .cs file
    please explain clearly jsulm sir

  • Lifetime Qt Champion

    @Rameshguru What should I explain clearly? You should explain clearly the problem. For that I asked you to post the whole error messages instead of the numbers LNK2020 and LNK2001. Can you please do so?
    And what do you want to add actually? Source code files or a library? For library @VRonin already explained how to do it.

Log in to reply