Every good developer knows never to re-invent the wheel, especially if there is software out there that has been tested by others, and has an established track record. As a developer using the .NET framework I’ve found some of these libraries invaluable, so I’m sharing them for some of the other dev’s out there with a brief outline of how to use.
Yedda Twitter Library.
I’ve used this on a number of very simple twitter projects, where I’ve just needed to send an update. As the site says its more of a wrapper for the Twitter API than an actual library, but none the less its an easy way to integrate with the service via a drop in dll. Here’s how to use it.
- Dim objYedda As New Yedda.Twitter
- Dim status as String
- Dim strTwitterUser as String = “username”
- Dim strTwitterPassword as String = “password”
- status = “Hello World”
- objYedda.Update(strTwitterUser, strTwitterPassword, strStatus, Yedda.Twitter.OutputFormatType.RSS)
This small section of code will update your Twitter stream (provided you have a reference to the DLL), and your username and password correct.
The FileHelpers library was created to stop developers from continuing to parse CSV. If you are doing any kind of importing and exporting within your application using the CSV format to get data in or out, look no further.
You can strong type your flat file simply by coding up a class that maps a data type to each record. This way data consistency, and import / export reliability can be tightened up on quite a bit. Writing out to a new file is also pretty easy once you’ve created your base classes defining the structure. Great little library for your toolkit.
First define the structure class…
- Public Class Product
- Public ProductName As String
- Public ProductCode As Integer
- End Class
Add a reference to the FileHelper.dll, and read from the file , casting to a array of product objects.
- Dim engine As New FileHelperEngine(GetType(Product))
- Dim myProduct As Product() = DirectCast(engine.ReadFile(“product.txt”), Product())
Perform actions on the array of Products.
- For Each pro As Product In myProduct)
Elmah stands for error logging module and handlers. It is a completely pluggable in system for error handling within your .NET app. It catches bot thrown and unhandled exceptions across the scope of your app, logs them, and allows you to browse the full stack trace, all without exposing the error to the users of your application. That’s useful for a number of reasons. Firstly you aren’t getting the performance hit of using debug=true within your application (which by the way you should never be using in a production environment anyway) – and it means you can still get to the bottom of little blips as and if they happen. Coolio.
Elmah works as an HTTP module, so it takes little or no effort to deploy on any project. Just configure a few bits and bobs, and away it goes. All of the configuration is performed in the configuration file – just telling it whether you want your errors logged in a database, in memory or in a txt file is as simple as changing some web config parameters. You can even grab recent errors via RSS and get notified like that.
Following in the same vein as Elmah – Log4Net is a port of the well known logging framework for Java log4J. Whilst Elmah concentrates on exceptions that are thrown, Log4Net allows a much more granualar approach to program debugging.
With log4net it is possible to enable logging at runtime without modifying the original application binary and without incurring a high performance cost. Multiple “levels” of logging can be set within your program as well, and so you can determine quickly where “fatal” errors occur, and where “warnings” occur that can be ignored in the safe running of your application.
Log4Net enables all of these things whilst providing the same level of control over the logging format and location as Elmah. You can decide whether you’d like your debug message sent to a database, a text file, or indeed a TCP port. Different “Appenders” define where and how to send the messages, so if there’s somewhere else you’d like to see errors, you can easily write your own appender to perform this. Again, the appenders are defined in the web.config file.
- Imports log4net
- Imports log4net.Config
- Private Shared log As log4net.ILog
- Public Sub Page_Load(Byval s as Object, Byval e As EventArgs) Handles MyBase.Load
- log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
- log.Debug(“Debug Message”)
- log.Warn(“Warning Message”)
- log.Fatal(“Fatal Message”)
- End Sub
Enterprise DT FTP Library
Enterprise DT is a great little FTP library, that performs all the needful without you getting your hands too dirty. It works with both web and offline applications, and again is a port of a Java library. I’ve used it for automating FTP tasks at the command line, sending photos between two sites automatically via FTP, and for sending feeds to google. It’s really easy to use, and saves you from having to write your own FTP operations. Fire it up, pass some usernames and passwords to it, and away we go. As below:
- Dim ftp as FTPConnection = new FTPConnection()
- ftpConnection.ServerAddress = “myserver”
- ftpConnection.UserName = userName
- ftpConnection.Password = password
- ftpConnection.UploadFile(localFilePath, remoteFileName)
The Html Agility Pack is a library for parsing HTML. It is particularly useful if you are doing any kind of scraping work, with the main object of the software to transform real world HTML into structured and parseable DOM structure. It supports plain XPATH or XSLT syntax for traversing through HTML, making loops and extraction of text a breeze. Knowing these two technologies isn’t a pre-requisite to using it, but it sure as heck helps. You don’t have to setup the WebRequest or anything to grab remote files, which is handy – as you’ll see from the example.
- Dim hw As New HtmlAgilityPack.HtmlWeb
- Dim doc As HtmlAgilityPack.HtmlDocument
- doc = hw.Load(“http://www.webdistortion.com”)
- For Each s As HtmlAgilityPack.HtmlNode In doc.DocumentNode.SelectNodes(“//a[@href]”)
- Dim att As HtmlAgilityPack.HtmlAttribute = s.Attributes(“href”)
- Response.Write(att.Value & vbCrLf)
Open Auth is slowly becoming the norm, with web apps many preferring its usage over other less secure forms of authentication. This library is a .NET implementation of OpenAuth, and is mighty useful if you need to get up and running quickly. You are sure to run into a web service that needs you to auth via it. Google, Yahoo, Netflix and Twitter all support OpenAuth to interact with their service. The code needed for open auth is more extensive than some of the other bits and bobs, and has been better explained by others. Some of these links are worth a look.
Microsoft AntiXSS library
This is one of the security packs that MS have released to help .NET developers write better, more secure code. Essentially it is an encoding library designed to help protect ASP.NET web-based applications from XSS attacks, and works on the principals of inclusion (white-listing) to accept valid characters. I’ve used it successfully on a couple of projects, and some of the pre-written methods have been rigourously tested by leading security experts.
C5 Collections – Collections for .NET
C5 provides functionality and data structures not provided by the standard .Net System.Collections.Generic namespace, such as persistent tree data structures, heap based priority queues, hash indexed array lists and linked lists, and events on collection changes. Also, it is more comprehensive than collection class libraries on other similar platforms, such as Java. Unlike many other collection class libraries, C5 is designed with a strict policy of supporting “code to interface not implementation”. Definitely worth a look.
Dependency Injection/Inversion of Control
- Unity Framework – Microsoft
- StructureMap – Jeremy Miller
- Castle Windsor
- Spring Framework
- Managed Extensibility Framework
- Microsoft Chart Controls for ASP.NET 3.5 SP1
- Microsoft Chart Controls for Winforms
- ZedGraph Charting
- NPlot – Charting for ASP.NET and WinForms
Automated Web Testing
- CSLA Framework – Business Objects Framework
- AForge.net – AI, computer vision, genetic algorithms, machine learning
- Enterprise Library 4.1 – Logging, Exception Management, Validation, Policy Injection
- Quartz.NET – Enterprise Job Scheduler for .NET Platform
- MiscUtil – Utilities by Jon Skeet
- Lucene.net – Text indexing and searching
- Json.NET – Linq over JSON
- Flee – expression evaluator
- PostSharp – AOP
- IKVM – brings the extensive world of Java libraries to .NET.
- FlickrNET – Flickr library for .NET
- PowerCollections – Power Collections for .NET
- Facebook.net – Facebook API interface.
- OpenPOP – OpenPOP.NET POP library for .NET