none
adding a dll do C# RRS feed

  • Question

  • I have a dll I want to include into my project but cannot figure out how to tell the IDE to do this?

    this should be common knowledge, I've been away, still getting my C-legs... need a bit of help.

    Thank you,

    BadButBit


    my code is perfect until i don't find a bug

    Saturday, April 13, 2019 3:41 PM

Answers

  • I have a dll I want to include into my project

    It is important to differentiate here what kind of DLL it is.

    If it is managed code (a DLL programmed in .NET) then, as mentioned in another reply, you can add a Reference to the DLL. By default, this will cause Visual Studio to copy the DLL to your bin folder every time you compile (although you can change this behavior if you need to). Therefore, your executable will be able to find it at runtime because it will be found in the same folder.

    However, if it is a binary DLL with conventional entry points (the kind that you would invoke using the DllImport attribute), then you cannot add a Reference. You can still add the DLL to the project using "Add existing item...", but Visual Studio will not know what to do with it other than keep it stored under the project folder. You will need to code an installer to deploy it wherever it needs to be for your executable to find it.

    Saturday, April 13, 2019 4:54 PM
    Moderator
  • What IDE are you using? In Visual studio its under references within the solution explorer:

    https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/ide/how-to-add-or-remove-references-by-using-the-reference-manager.md


    Fouad Roumieh


    Saturday, April 13, 2019 4:39 PM

All replies

  • What IDE are you using? In Visual studio its under references within the solution explorer:

    https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/ide/how-to-add-or-remove-references-by-using-the-reference-manager.md


    Fouad Roumieh


    Saturday, April 13, 2019 4:39 PM
  • I have a dll I want to include into my project

    It is important to differentiate here what kind of DLL it is.

    If it is managed code (a DLL programmed in .NET) then, as mentioned in another reply, you can add a Reference to the DLL. By default, this will cause Visual Studio to copy the DLL to your bin folder every time you compile (although you can change this behavior if you need to). Therefore, your executable will be able to find it at runtime because it will be found in the same folder.

    However, if it is a binary DLL with conventional entry points (the kind that you would invoke using the DllImport attribute), then you cannot add a Reference. You can still add the DLL to the project using "Add existing item...", but Visual Studio will not know what to do with it other than keep it stored under the project folder. You will need to code an installer to deploy it wherever it needs to be for your executable to find it.

    Saturday, April 13, 2019 4:54 PM
    Moderator