Search code examples
c#visual-studioreferencelibraries

Using libraries in C# (Visual Studio)


I've been trying to download and use some libraries in my C# project but haven't succeed adding them to the project nor finding anywhere how to do it. The instructions says "simply add the files in the sourcecode folder into your project, compile and have a tea!" (the library is this by the way: http://spreadsheetlight.com/). But I don't think I compiled it properly and it's unable to find the functions/methods in the library and I get an error. Some help would therefore be deeply appreciated!

Thanks in advance! Axel


Solution

  • I clicked your link, and downloaded whatever it was. :) It came as a zip folder. Obviously the first thing you need to do, is unzip your folder. Then you should end up with this: enter image description here

    The important thing here, is the SpreadsheetLight.dll...

    Next, go to your project that you want this in, right click on the references folder and click Add reference:enter image description here

    A new window should pop up. Click on the browse tab, find your extracted folder, and select the SpreadsheetLight.dll file:

    enter image description here

    Choose OK.

    Then view your code, find where all the imports are (i.e. using System;), and insert the following:

    using SpreadsheetLight;
    

    or go further to:

    using SpreadsheetLight.Charts;
    

    You can then access members of the library:

    enter image description here

    That is how you would generally use a library in Visual Studio... Good Luck!