How to use open source library in C#?
I would like to use log4j.net in my windows forms project. However I have never used any library or dll in .NET. How to do it? I look at the site, but I 开发者_C百科can't find it.
I'm using visual studio 2010.
Add the log4net assembly to your project:
- Browse to the log4net downloads page and download the latest log4net archive
(right now the latest version is 1.2.10). - Extract that archive and place the files somewhere to your project
(for example in a folder likeyourproject/lib/log4net
). - In Visual Studio right click in your project on the References folder and click on Add Reference....
- Browse to the folder where your assemblies are (see point 3) and choose the
log4net.dll
assembly.
Here are some nice basic tutorial for the first steps using Log4Net:
- Log4Net Tutorial pt 1: Getting Started
- Using Log4Net in 4 Simple Steps
- Log error or exception using Log4Net
In your project, you need add a reference to the library, usually by selecting the DLL from the references dialog.
A package manager, NuGet, has been created as an add on to Visual Studio 2010, which lets you select libraries - it will download and set them up for you.
Whichever way you do this, you will now be able to use the library - in a code file, use the using
directive to import the namespace, then you can use the classes and other public members of the library in your code (though you could use the fully qualified name every time, if you wish to).
This has nothing to do with a library being open source or not, by the way.
you can easily get now using NuGet package manager in visual studio 2010
Write this command in Package manager console.
Install-Package log4net
See this link
Do you have any specific problems?
Check link below and maybe ask a question if you are stuck on something:
http://sadi02.wordpress.com/2008/06/29/log4net-tutorial-in-c-net-how-can-i-show-log-in-a-file/
精彩评论