Posts
133
Comments
328
Trackbacks
0
May 2010 Entries
Building a plug-in for Windows Live Writer

This tutorial will show you how to build a plug-in for Windows Live Writer. Windows Live Writer is a blogging tool that Microsoft provides for free. It includes an open API for .NET developers to create custom plug-ins. In this tutorial, I will show you how easy it is to build one.

Full source and binaries are now hosted on CodePlex.

Open VS2008 or VS2010 and create a new project. Set the target framework to 2.0, Application Type to Class Library and give it a name. In this tutorial, we are going to create a plug-in that generates a twitter message with your blog post name and a TinyUrl link to the blog post.  It will do all of this automatically after you publish your post.

image

Once, we have a new projected created. We need to setup the references.

Add a reference to the WindowsLive.Writer.Api.dll located in the C:\Program Files (x86)\Windows Live\Writer\ folder, if you are using X64 version of Windows.

image

You will also need to add a reference to

  • System.Windows.Forms
  • System.Web

from the .NET tab as well.

Once that is complete, add your “using” statements so that it looks like whats shown below:

Live Writer Plug-In "Using"
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using WindowsLive.Writer.Api;
  5. using System.Web;

Now, we are going to setup some build events to make it easier to test our custom class. Go into the Properties of your project and select Build Events, click edit the Post-build and copy/paste the following line:

XCOPY /D /Y /R "$(TargetPath)" "C:\Program Files (x86)\Windows Live\Writer\Plugins\"

Your screen should look like the one pictured below:

image

Next, we are going to launch an external program on debug. Click the debug tab and enter

C:\Program Files (x86)\Windows Live\Writer\WindowsLiveWriter.exe

Your screen should look like the one pictured below:

image

 

Now we have a blank project and we need to add some code. We start with adding the attributes for the Live Writer Plugin. Before we get started creating the Attributes, we need to create a GUID. This GUID will uniquely identity our plug-in.

So, to create a GUID follow the steps in VS2008/2010.

Click Tools from the VS Menu ->Create GUID

 

 

image

image

It will generate a GUID like the one listed below:

 

GUID
  1. <Guid("56ED8A2C-F216-420D-91A1-F7541495DBDA")>

We only want what’s inside the quotes, so your final product should be: "56ED8A2C-F216-420D-91A1-F7541495DBDA". Go ahead and paste this snipped into your class just above the public class.

Live Writer Plug-In Attributes
  1. [WriterPlugin("56ED8A2C-F216-420D-91A1-F7541495DBDA",
  2.    "Generate Twitter Message",
  3.    Description = "After your new post has been published, this plug-in will attempt to generate a Twitter status messsage with the Title and TinyUrl link.",
  4.    HasEditableOptions = false,
  5.    Name = "Generate Twitter Message",
  6.    PublisherUrl = "http://michaelcrump.net")]
  7. [InsertableContentSource("Generate Twitter Message")]

So far, it should look like the following:

image

 

 

Next, we need to implement the PublishNotifcationHook class and override the OnPostPublish. I’m not going to dive into what the code is doing as you should be able to follow pretty easily. The code below is the entire code used in the project.

PublishNotificationHook
  1. public class Class1 :  PublishNotificationHook
  2.  {
  3.      public override void OnPostPublish(System.Windows.Forms.IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish)
  4.      {
  5.          if (!publish) return;
  6.          if (string.IsNullOrEmpty(publishingContext.PostInfo.Permalink))
  7.          {
  8.              PluginDiagnostics.LogError("Live Tweet didn't execute, due to blank permalink");
  9.          }
  10.          else
  11.          {
  12.  
  13.              var strBlogName = HttpUtility.UrlEncode("#blogged : " + publishingContext.PostInfo.Title);  //Blog Post Title
  14.              var strUrlFinal = getTinyUrl(publishingContext.PostInfo.Permalink); //Blog Permalink URL Converted to TinyURL
  15.              System.Diagnostics.Process.Start("http://twitter.com/home?status=" + strBlogName + strUrlFinal);
  16.  
  17.          }
  18.      }

We are going to go ahead and create a method to create the short url (tinyurl).

TinyURL Helper Method
  1. private static string getTinyUrl(string url)
  2. {
  3.     var cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
  4.     if (!cmpUrl.IsPrefix(url, "http://tinyurl.com"))
  5.     {
  6.         var address = "http://tinyurl.com/api-create.php?url=" + url;
  7.         var client = new System.Net.WebClient();
  8.         return (client.DownloadString(address));
  9.     }
  10.     return (url);
  11. }

Go ahead and build your project, it should have copied the .DLL into the Windows Live Writer Plugin Directory. If it did not, then you will want to check your configuration.

Once that is complete, open Windows Live Writer and select Tools-> Options-> Plug-ins and enable your plug-in that you just created.

Your screen should look like the one pictured below:

image

Go ahead and click OK and publish your blog post. You should get a pop-up with the following:

image

Hit OK and It should open a Twitter and either ask for a login or fill in your status as shown below:

image 

That should do it, you can do so many other things with the API. I suggest that if you want to build something really useful consult the MSDN pages. This plug-in that I created was perfect for what I needed and I hope someone finds it useful. 

Posted On Sunday, May 30, 2010 10:18 AM | Feedback (1)
Tools and Utilities for the .NET Developer

image

 You can reach this page anytime at http://tools.michaelcrump.net

Thanks to everyone that has contributed so far, we are getting several thousands hits from all sorts of developers a day. Recent Contributors include: Deependra Solanky, Grant, Klaus, James, BlueCollarCritic and Bob Koehn

Tweet this list!
Add a link to my site!
Add me to twitter!

This is a list of the tools/utilities that I use to do my job/hobby. I wanted this page to load fast and contain information that only you care about. If I have missed a tool that you like, feel free to contact me and I will add it to the list. Also, this list took a lot of time to complete. Please do not steal my work, if you like the page then please link back to my site. I will keep the links/information updated as new tools/utilities are created. 

Windows/.NET Development – This is a list of tools that any Windows/.NET developer should have in his bag. I have used at some point in my career everything listed on this page and below is the tools worth keeping.

Name Description License
7-Zip 7-Zip is a file archiver with a high compression ratio. Free
AnkhSVN Subversion support for Visual Studio. It also works with VS2010. Free
Aurora XAML Designer One of the best XAML creation tools available. Has a ton of built in templates that you can copy/paste into VS2010. COST/Trial
BeyondCompare Beyond Compare 3 is the ideal tool for comparing files and folders on your Windows or Linux system. Visualize changes in your code and carefully reconcile them. COST/Trial
BuildIT Automated Task Tool Its main purpose is to automate tasks, whether it is the final packaging of a product, an automated daily build, maybe sending out a mailing list, even backing-up files. Free
C Sharper for VB Convert VB to C#. COST
CLRProfiler Analyze and improve the behavior of your .NET app. Free
CodeRush Direct competitor to ReSharper, contains similar feature. This is one of those decide for yourself. COST/Trial
Disk2VHD Disk2vhd is a utility that creates VHD (Virtual Hard Disk - Microsoft's Virtual Machine disk format) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). Free
Eazfuscator.NET Is a free obfuscator for .NET. The main purpose is to protect intellectual property of software. Free
ELMAH ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment. Free
EQATEC Profiler Make your .NET app run faster. No source code changes are needed. Just point the profiler to your app, run the modified code, and get a visual report. Free
Expression Studio 3/4 Comes with Web, Blend, Sketch Flow and more. You can create websites, produce beautiful XAML and more. COST/Trial
Expresso The award-winning Expresso editor is equally suitable as a teaching tool for the beginning user of regular expressions or as a full-featured development environment for the experienced programmer or web designer with an extensive knowledge of regular expressions. Free
Fiddler Fiddler is a web debugging proxy which logs all HTTP(s) traffic between your computer and the internet. Free
Firebug Powerful Web development tool. If you build websites, you will need this. Free
FxCop FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements. Free
GAC Browser and Remover Easy way to remove multiple assemblies from the GAC. Assemblies registered by programs like Install Shield can also be removed. Free
GAC Util The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache. Free
HelpScribble Help Scribble is a full-featured, easy-to-use help authoring tool for creating help files from start to finish. You can create Win Help (.hlp) files, HTML Help (.chm) files, a printed manual and online documentation (on a web site) all from the same Help Scribble project. COST/Trial
IETester IETester is a free Web Browser that allows you to have the rendering and JavaScript engines of IE9 preview, IE8, IE7 IE 6 and IE5.5 on Windows 7, Vista and XP, as well as the installed IE in the same process. Free
iTextSharp iText# (iTextSharp) is a port of the iText open source java library for PDF generation written entirely in C# for the .NET platform. Use the iText mailing list to get support. Free
Kaxaml Kaxaml is a lightweight XAML editor that gives you a "split view" so you can see both your XAML and your rendered content. Free
LINQPad LinqPad lets you interactively query databases in a LINQ. Free
Linquer Many programmers are familiar with SQL and will need a help in the transition to LINQ. Sometimes there are complicated queries to be written and Linqer can help by converting SQL scripts to LINQ. COST/Trial
LiquidXML Liquid XML Studio 2010 is an advanced XML developers toolkit and IDE, containing all the tools needed for designing and developing XML schema and applications. COST/Trial
Log4Net log4net is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the excellent log4j framework to the .NET runtime. We have kept the framework similar in spirit to the original log4j while taking advantage of new features in the .NET runtime. For more information on log4net see the features document. Free
Microsoft Web Platform Installer The Microsoft Web Platform Installer 2.0 (Web PI) is a free tool that makes getting the latest components of the Microsoft Web Platform, including Internet Information Services (IIS), SQL Server Express, .NET Framework and Visual Web Developer easy. Free
Mono Development Don't have Visual Studio - no problem! This is an open Source C# and .NET development environment for Linux, Windows, and Mac OS X Free
Net Mass Downloader While it’s great that Microsoft has released the .NET Reference Source Code, you can only get it one file at a time while you’re debugging. If you’d like to batch download it for reading or to populate the cache, you’d have to write a program that instantiated and called each method in the Framework Class Library. Fortunately, .NET Mass Downloader comes to the rescue! Free
nMap Nmap ("Network Mapper") is a free and open source (license) utility for network exploration or security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Free
NoScript (Firefox add-in) The NoScript Firefox extension provides extra protection for Firefox, Flock, Seamonkey and other Mozilla-based browsers: this free, open source add-on allows JavaScript, Java and Flash and other plug-ins to be executed only by trusted web sites of your choice (e.g. your online bank), and provides the most powerful Anti-XSS protection available in a browser. Free
NotePad 2 Notepad2, a fast and light-weight Notepad-like text editor with syntax highlighting. This program can be run out of the box without installation, and does not touch your system's registry. Free
PageSpy PageSpy is a small add-on for Internet Explorer that allows you to select any element within a webpage, select an option in the context menu, and view detailed information about both the coding behind the page and the element you selected. Free
Phrase Express PhraseExpress manages your frequently used text snippets in customizable categories for quick access. Free
PowerGui PowerGui is a free community for PowerGUI, a graphical user interface and script editor for Microsoft Windows PowerShell! Free
Powershell Comes with Win7, but you can automate tasks by using the .NET Framework. Great for network admins. Free
Process Explorer Ever wondered which program has a particular file or directory open? Now you can find out. Process Explorer shows you information about which handles and DLLs processes have opened or loaded. Also, included in the SysInterals Suite. Free
Process Monitor Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. Free
Redmine Redmine is a flexible project management web application. Written using Ruby on Rails framework, it is cross-platform and cross-database. Free
Reflector Explore and analyze compiled .NET assemblies, viewing them in C#, Visual Basic, and IL. This is an Essential for any .NET developer. Free
Regular Expression Library Stuck on a Regular Expression but you think someone has already figured it out? Chances are they have. Free
Regulator Regulator makes Regular Expressions easy. This is a must have for a .NET Developer. Free
RenameMaestro RenameMaestro is probably the easiest batch file renamer you'll find to instantly rename multiple files COST
ReSharper The one program that I cannot live without. Supports VS2010 and offers simple refactoring, code analysis/assistance/cleanup/templates. One of the few applications that is worth the $$$. COST/Trial
ScrewTurn Wiki ScrewTurn Wiki allows you to create, manage and share wikis. A wiki is a collaboratively-edited, information-centered website: the most famous is Wikipedia. Free
SharpDevelop What is #develop? SharpDevelop is a free IDE for C# and VB.NET projects on Microsoft's .NET platform. Free
Show Me The Template Show Me The Template is a tool for exploring the templates, be their data, control or items panel, that comes with the controls built into WPF for all 6 themes. Free
SnippetCompiler Compiles code snippets without opening Visual Studio. It does not support .NET 4. Free
SQL Formatter Instantly format SQL code! COST/Trial
SQL Prompt SQL Prompt is a plug-in that increases how fast you can work with SQL. It provides code-completion for SQL server, reformatting, db schema information and snippets. Awesome! COST/Trial
SQLinForm SQLinForm is an automatic SQL code formatter for all major databases  including ORACLE, SQL Server, DB2, UDB, Sybase, Informix, PostgreSQL, Teradata, MySQL, MS Access etc. with over 70 formatting options. COST/OnlineFree
SSMS Tools SSMS Tools Pack is an add-in for Microsoft SQL Server Management Studio (SSMS) including SSMS Express. Free
Storm STORM is a free and open source tool for testing web services. Free
Telerik Code Convertor Convert code from VB to C Sharp and Vice Versa. Free
TurtoiseSVN TortoiseSVN is a really easy to use Revision control / version control / source control software for Windows.Since it's not an integration for a specific IDE you can use it with whatever development tools you like. Free
UltraEdit UltraEdit is the ideal text, HTML and hex editor, and an advanced PHP, Perl, Java and JavaScript editor for programmers. UltraEdit is also an XML editor including a tree-style XML parser. An industry-award winner, UltraEdit supports disk-based 64-bit file handling (standard) on 32-bit Windows platforms (Windows 2000 and later). COST/Trial
UltraEdit Studio UEStudio offers all the functionality of UltraEdit plus other exciting and powerful features! Whether you are simply editing text, building applications, maintaining databases, or constructing websites, UEStudio's stunning array of innovative features offers the functionality of a bonafide IDE at an unsurpassed value. COST/Trial
Virtual Windows XP Comes with some W7 version and allows you to run WinXP along side W7. Free
VirtualBox Virtualization by Sun Microsystems. You can virtualize Windows, Linux and more. Free
Visual Log Parser SQL queries against a variety of log files and other system data sources. Free
WinMerge WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle. Free
Wireshark Wireshark is one of the best network protocol analyzer's for Unix and windows. This has been used several times to get me out of a bind. Free
XML Notepad 07 Old, but still one of my favorite XML viewers. Free

Productivity Tools – This is the list of tools that I use to save time or quickly navigate around Windows.

Name

Description License
AutoHotKey Automate almost anything by sending keystrokes and mouse clicks. You can write a mouse or keyboard macro by hand or use the macro recorder. Free
CLCL CLCL is clipboard caching utility. Free
Ditto Ditto is an extension to the standard windows clipboard. It saves each item placed on the clipboard allowing you access to any of those items at a later time. Ditto allows you to save any type of information that can be put on the clipboard, text, images, html, custom formats, ..... Free
Evernote Remember everything from notes to photos. It will synch between computers/devices. Free
InfoRapid Inforapid is a search tool that will display all you search results in a html like browser. If you click on a word in that browser, it will start another search to the word you clicked on. Handy if you want to trackback something to it's true origin. The word you looked for will be highlighted in red. Clicking on the red word will open the containing file in a text based viewer. Clicking on any word in the opened document will start another search on that word. Free
KatMouse The prime purpose of the KatMouse utility is to enhance the functionality of mice with a scroll wheel, offering 'universal' scrolling: moving the mouse wheel will scroll the window directly beneath the mouse cursor (not the one with the keyboard focus, which is default on Windows OSes). This is a major increase in the usefulness of the mouse wheel. Free
ScreenR Instant Screencast with nothing to download. Works with Mac or PC and free. Free
Start++ Start++ is an enhancement for the Start Menu in Windows Vista. It also extends the Run box and the command-line with customizable commands.  For example, typing "w Windows Vista" will take you to the Windows Vista page on Wikipedia! Free
Synergy Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems, each with its own display, without special hardware. It's intended for users with multiple computers on their desk since each system uses its own monitor(s). Free
Texter Texter lets you define text substitution hot strings that, when triggered, will replace hotstring with a larger piece of text. By entering your most commonly-typed snippets of text into Texter, you can save countless keystrokes in the course of the day. Free
Total Commander File handling, FTP, Archive handling and much more. Even works with Win3.11. COST/Trial Available
Wizmouse WizMouse is a mouse enhancement utility that makes your mouse wheel work on the window currently under the mouse pointer, instead of the currently focused window. This means you no longer have to click on a window before being able to scroll it with the mouse wheel. This is a far more comfortable and practical way to make use of the mouse wheel. Free
Xmarks Bookmark sync and search between computers. Free

General Utilities – This is a list for power user users or anyone that wants more out of Windows. I usually install a majority of these whenever I get a new system.

Name

Description License
µTorrent µTorrent is a lightweight and efficient BitTorrent client for Windows or Mac with many features. I use this for downloading LEGAL media. Free
Audacity Audacity® is free, open source software for recording and editing sounds. It is available for Mac OS X, Microsoft Windows, GNU/Linux, and other operating systems. Learn more about Audacity... Also check our Wiki and Forum for more information. Free
AVast Free FREE Antivirus. Free
CD Burner XP Pro CDBurnerXP is a free application to burn CDs and DVDs, including Blu-Ray and HD-DVDs. It also includes the feature to burn and create ISOs, as well as a multilanguage interface. Free
CDEX You can extract digital audio CDs into mp3/wav. Free
Combofix Combofix is a freeware (a legitimate spyware remover created by sUBs), Combofix was designed to scan a computer for known malware, spyware (SurfSideKick, QooLogic, and Look2Me as well as any other combination of the mentioned spyware applications) and remove them. Free
Cpu-Z Provides information about some of the main devices of your system. Free
Cropper Cropper is a screen capture utility written in C#. It makes it fast and easy to grab parts of your screen. Use it to easily crop out sections of vector graphic files such as Fireworks without having to flatten the files or open in a new editor. Use it to easily capture parts of a web site, including text and images. It's also great for writing documentation that needs images of your application or web site. Free
DropBox Drag and Drop files to sync between computers. Free
DVD-Fab Converts/Copies DVDs/Blu-Ray to different formats. (like mp4, mkv, avi) COST/Trial Available
FastStone Capture FastStone Capture is a powerful, lightweight, yet full-featured screen capture tool that allows you to easily capture and annotate anything on the screen including windows, objects, menus, full screen, rectangular/freehand regions and even scrolling windows/web pages. Free
ffdshow FFDShow is a DirectShow decoding filter for decompressing DivX, XviD, H.264, FLV1, WMV, MPEG-1 and MPEG-2, MPEG-4 movies. Free
File Locator Pro Search and navigate through all your important data with FileLocator Pro™. Its unique features make it possible to dig out information in even the most obscure file formats. Cost/Trial Available
Filezilla FileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive graphical user interface. You can also download a server version. Free
FireFox Web Browser, do you really need an explanation? Free
FireGestures A customizable mouse gestures extension which enables you to execute various commands and user scripts with five types of gestures. Free
FoxIt Reader Light weight PDF viewer. You should install this with the advanced setting or it will install a toolbar and setup some shortcuts. Free
gSynchIt Synch Gmail and Outlook. Even supports Outlook 2010 32/64 bit COST/Trial Available
Hulu Desktop At home or in a hotel, this has replaced my cable/satellite subscription. Free
ImgBurn ImgBurn is a lightweight CD / DVD / HD DVD / Blu-ray burning application that everyone should have in their toolkit! Free
Infrarecorder InfraRecorder is a free CD/DVD burning solution for Microsoft Windows. It offers a wide range of powerful features; all through an easy to use application interface and Windows Explorer integration. Free
KeePass KeePass is a free open source password manager, which helps you to manage your passwords in a secure way. Free
LastPass Another password management, synchronize between browsers, automatic form filling and more. Free
Live Essentials One download and lots of programs including Mail, Live Writer, Movie Maker and more! Free
Monitores MonitorES is a small windows utility that helps you to turnoff monitor display when you lock down your machine.Also when you lock your machine, it will pause all your running media programs & set your IM status message to "Away" / Custom message(via options) and restore it back to normal when you back. Free
mRemote mRemote is a full-featured, multi-tab remote connections manager. Free
Open Office OpenOffice.org 3 is the leading open-source office software suite for word processing, spreadsheets, presentations, graphics, databases and more. It is available in many languages and works on all common computers. It stores all your data in an international open standard format and can also read and write files from other common office software packages. It can be downloaded and used completely free of charge for any purpose. Free
Paint.NET Simple, intuitive, and innovative user interface for editing photos. Free
Picasa Picasa is free photo editing software from Google that makes your pictures look great. Free
Pidgin Pidgin is an easy to use and free chat client used by millions. Connect to AIM, MSN, Yahoo, and more chat networks all at once. Free
PING PING is a live Linux ISO, based on the excellent Linux From Scratch (LFS) documentation. It can be burnt on a CD and booted, or integrated into a PXE / RIS environment. Free
Putty PuTTY is an SSH and telnet client, developed originally by Simon Tatham for the Windows platform. Free
Revo Uninstaller Revo Uninstaller Pro helps you to uninstall software and remove unwanted programs installed on your computer easily! Even if you have problems uninstalling and cannot uninstall them from "Windows Add or Remove Programs" control panel applet.Revo Uninstaller is a much faster and more powerful alternative to "Windows Add or Remove Programs" applet! It has very powerful features to uninstall and remove programs. Free
Security Essentials Microsoft Security Essentials is a new, free consumer anti-malware solution for your computer. Free
SetupVirtualCloneDrive Virtual CloneDrive works and behaves just like a physical CD/DVD drive, however it exists only virtually. Point to the .ISO file and it appears in Windows Explorer as a Drive. Free
Shark 007 Codec Pack Play just about any file format with this download. Also includes my W7 Media Playlist Generator. Free
Snagit 9 Screen Capture on steroids. Add arrows, captions, etc to any screenshot. COST/Trial Available
SysinternalsSuite Go ahead and download the entire sys internals suite. I have mentioned multiple programs in this suite already. Free
TeraCopy TeraCopy is a compact program designed to copy and move files at the maximum possible speed, providing the user with a lot of features. Free for Home
TrueCrypt Free open-source disk encryption software for Windows 7/Vista/XP, Mac OS X, and Linux Free
TweetDeck Fully featured Twitter client. Free
UltraISO UltraISO is an ISO CD/DVD image file creating/editing/converting tool and a bootable CD/DVD maker. COST/Trial Available
UltraVNC UltraVNC is a powerful, easy to use and free software that can display the screen of another computer (via internet or network) on your own screen. The program allows you to use your mouse and keyboard to control the other PC remotely. It means that you can work on a remote computer, as if you were sitting in front of it, right from your current location. Free
Unlocker Unlocks locked files. Pretty simple right? Free
VLC Media Player VLC media player is a highly portable multimedia player and multimedia framework capable of reading most audio and video formats Free
Windows 7 Media Playlist This program is special to my heart because I wrote it. It has been mentioned on podcast and various websites. It allows you to quickly create wvx video playlist for Windows Media Center. Free
WinRAR WinRAR is a powerful archive manager. It can backup your data and reduce the size of email attachments, decompress RAR, ZIP and other files downloaded from Internet and create new archives in RAR and ZIP file format. COST/Trial Available

Blogging – I use the following for my blog.

Name Description License
Insert Code for Windows Live Writer Insert Code for Windows Live Writer will format a snippet of text in a number of programming languages such as C#, HTML, MSH, JavaScript, Visual Basic and TSQL. Free
LiveWriter Included in Live Essentials, but the ultimate in Windows Blogging Free
PasteAsVSCode Plug-in for Windows Live Writer that pastes clipboard content as Visual Studio code. Preserves syntax highlighting, indentation and background color. Converts RTF, outputted by Visual Studio, into HTML. Free

Desktop Management – The list below represent the best in Windows Desktop Management.

Name Description License
7 Stacks Allows users to have "stacks" of icons in their taskbar. Free
Executor Executor is a multi purpose launcher and a more advanced and customizable version of windows run. Free
Fences Fences is a program that helps you organize your desktop and can hide your icons when they are not in use. Free
RocketDock Rocket Dock is a smoothly animated, alpha blended application launcher. It provides a nice clean interface to drop shortcuts on for easy access and organization. With each item completely customizable there is no end to what you can add and launch from the dock. Free
WindowsTab Tabbing is an essential feature of modern web browsers. Window Tabs brings the productivity of tabbed window management to all of your desktop applications. Free
Posted On Tuesday, May 25, 2010 9:16 PM | Feedback (26)
F# for the C# Programmer

Are you a C# Programmer and can’t make it past a day without seeing or hearing someone mention F#?  Today, I’m going to walk you through your first F# application and give you a brief introduction to the language. Sit back this will only take about 20 minutes.

Introduction

Microsoft's F# programming language is a functional language for the .NET framework that was originally developed at Microsoft Research Cambridge by Don Syme. In October 2007, the senior vice president of the developer division at Microsoft announced that F# was being officially productized to become a fully supported .NET language and professional developers were hired to create a team of around ten people to build the product version. In September 2008, Microsoft released the first Community Technology Preview (CTP), an official beta release, of the F# distribution . In December 2008, Microsoft announced that the success of this CTP had encouraged them to escalate F# and it is now will now be shipped as one of the core languages in Visual Studio 2010 , alongside C++, C# 4.0 and VB.

The F# programming language incorporates many state-of-the-art features from programming language research and ossifies them in an industrial strength implementation that promises to revolutionize interactive, parallel and concurrent programming.

 

 

Advantages of F#

F# is the world's first language to combine all of the following features:

  • Type inference: types are inferred by the compiler and generic definitions are created automatically.
  • Algebraic data types: a succinct way to represent trees.
  • Pattern matching: a comprehensible and efficient way to dissect data structures.
  • Active patterns: pattern matching over foreign data structures.
  • Interactive sessions: as easy to use as Python and Mathematica.
  • High performance JIT compilation to native code: as fast as C#.
  • Rich data structures: lists and arrays built into the language with syntactic support.
  • Functional programming: first-class functions and tail calls.
  • Expressive static type system: finds bugs during compilation and provides machine-verified documentation.
  • Sequence expressions: interrogate huge data sets efficiently.
  • Asynchronous workflows: syntactic support for monadic style concurrent programming with cancellations.
  • Industrial-strength IDE support: multithreaded debugging, and graphical throwback of inferred types and documentation.
  • Commerce friendly design and a viable commercial market.

Lets try a short program in C# then F# to understand the differences.

Using C#: Create a variable and output the value to the console window:

Sample Program.
  1. using System;
  2.  
  3. namespace ConsoleApplication9
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var a = 2;
  10.             Console.WriteLine(a);
  11.             Console.ReadLine();
  12.         }
  13.     }
  14. }

 

 

 

 

image

A breeze right? 14 Lines of code. We could have condensed it a bit by removing the “using” statment and tossing the namespace. But this is the typical C# program.

Using F#: Create a variable and output the value to the console window:

To start, open Visual Studio 2010 or Visual Studio 2008. Note: If using VS2008, then please download the SDK first before getting started. If you are using VS2010 then you are already setup and ready to go.

So, click File-> New Project –> Other Languages –> Visual F# –> Windows –> F# Application. You will get the screen below.

image

 

Go ahead and enter a name and click OK.

Now, you will notice that the Solution Explorer contains the following:

image

Double click the Program.fs and enter the following information. Hit F5 and it should run successfully.

 

Sample Program.
  1. open System
  2. let a = 2       
  3. Console.WriteLine a

As Shown below:

image

Hmm, what? F# did the same thing in 3 lines of code. Show me the interactive evaluation that I keep hearing about.

The F# development environment for Visual Studio 2010 provides two different modes of execution for F# code:

  • Batch compilation to a .NET executable or DLL. (This was accomplished above).
  • Interactive evaluation. (Demo is below)

The interactive session provides a > prompt, requires a double semicolon ;; identifier at the end of a code snippet to force evaluation, and returns the names (if any) and types of resulting definitions and values.

To access the F# prompt, in VS2010 Goto View –> Other Window then F# Interactive.

Once you have the interactive window type in the following expression: 2+3;; as shown in the screenshot below:

image

 

I hope this guide helps you get started with the language, please check out the following books for further information.

F# Books for further reading

 

Foundations of F#
Foundations of F#

Author: Robert Pickering
An introduction to functional programming with F#. Including many samples, this book walks through the features of the F# language and libraries, and covers many of the .NET Framework features which can be leveraged with F#.

 

 

 

Functional Programming for the Real World: With Examples in F# and C#
Functional Programming for the Real World: With Examples in F# and C#

Authors: Tomas Petricek and Jon Skeet
An introduction to functional programming for existing C# developers written by Tomas Petricek and Jon Skeet. This book explains the core principles using both C# and F#, shows how to use functional ideas when designing .NET applications and presents practical examples such as design of domain specific language, development of multi-core applications and programming of reactive applications.

Posted On Saturday, May 22, 2010 6:43 PM | Feedback (1)
Stepping outside Visual Studio IDE [Part 2 of 2] with Mono 2.6.4

Continuing part 2 of my Stepping outside the Visual Studio IDE, is the open-source Mono Project.

Mono is a software platform designed to allow developers to easily create cross platform applications. Sponsored by Novell (http://www.novell.com/), Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime. A growing family of solutions and an active and enthusiastic contributing community is helping position Mono to become the leading choice for development of Linux applications.

So, to clarify. You can use Mono to develop .NET applications that will run on Linux, Windows or Mac. It’s basically a IDE that has roots in Linux. Let’s first look at the compatibility:

Compatibility

Moma48.png

If you already have an application written in .Net, you can scan your application with the Mono Migration Analyzer (MoMA) to determine if your application uses anything not supported by Mono.

The current release version of Mono is 2.6. (Released December 2009)

The easiest way to describe what Mono currently supports is:
Everything in .NET 3.5 except WPF and WF, limited WCF.

Here is a slightly more detailed view, by .NET framework version:

Implemented

  • C# 3.0
  • System.Core
  • LINQ
  • ASP.Net 3.5
  • ASP.Net MVC
  • C# 2.0 (generics)
  • Core Libraries 2.0: mscorlib, System, System.Xml
  • ASP.Net 2.0 - except WebParts
  • ADO.Net 2.0
  • Winforms/System.Drawing 2.0 - does not support right-to-left
  • C# 1.0
  • Core Libraries 1.1: mscorlib, System, System.Xml
  • ASP.Net 1.1
  • ADO.Net 1.1
  • Winforms/System.Drawing 1.1

Partially Implemented

  • LINQ to SQL - Mostly done, but a few features missing
  • WCF - silverlight 2.0 subset completed

Not Implemented

  • WPF - no plans to implement
  • WF - Will implement WF 4 instead on future versions of Mono.
  • System.Management - does not map to Linux
  • System.EnterpriseServices - deprecated

Links to documentation.

The Official Mono FAQ’s

Links to binaries.

Mono IDE Latest Version is 2.6.4


That's it, nothing more is required except to compile and run .net code in Linux.

Installation

After landing on the mono project home page, you can select which platform you want to download.

image

I typically pick the Virtual PC image since I spend all of my day using Windows 7. Go ahead and pick whatever version is best for you. The Virtual PC image comes with Suse Linux.

Once the image is launch, you will see the following:

image

 

 

I’m not going to go through each option but its best to start with “Start Here” icon. It will provide you with information on new projects or existing VS projects.

After you get Mono installed, it's probably a good idea to run a quick Hello World program to make sure everything is setup properly. This allows you to know that your Mono is working before you try writing or running a more complex application.

To write a "Hello World" program follow these steps:

  1. Start Mono Development Environment.
  2. Create a new Project:
    1. File->New->Solution
    2. Select "Console Project" in the category list.
    3. Enter a project name into the Project name field, for example, "HW Project".
    4. Click "Forward"
    5. Click “Packaging” then OK.
  3. You should have a screen very simular to a VS Console App.
  4. Click the "Run" button in the toolbar (Ctrl-F5).
  5. Look in the Application Output and you should have the “Hello World!”
  6. Your screen should look like the screen below.

image

That should do it for a simple console app in mono.

To test out an ASP.NET application, simply copy your code to a new directory in /srv/www/htdocs, then visit the following URL:

http://localhost/directoryname/page.aspx

where directoryname is the directory where you deployed your application and page.aspx is the initial page for your software.

Databases

You can continue to use SQL server database or use MySQL, Postgress, Sybase, Oracle, IBM’s DB2 or SQLite db.

Conclusion

I hope this brief look at the Mono IDE helps someone get acquainted with development outside of VS. As always, I welcome any suggestions or comments.

Posted On Wednesday, May 19, 2010 10:24 AM | Feedback (0)
Stepping outside Visual Studio IDE [Part 1 of 2] with Eclipse

imageIf you're walking down the right path and you're willing to keep walking, eventually you'll make progress." – Barack Obama

In my quest to become a better programmer, I’ve decided to start the process of learning Java. I will be primary using the Eclipse Language IDE. I will not bore you with the history just what is needed for a .NET developer to get up and running. I will provide links, screenshots and a few brief code tutorials.

Links to documentation.

The Official Eclipse FAQ’s

Links to binaries.

Eclipse IDE for Java EE Developers the Galileo Package (based on Eclipse 3.5 SR2) 
Sun Developer Network – Java Eclipse officially recommends Java version 5 (also known as 1.5), although many Eclipse users use the newer version 6 (1.6).

That's it, nothing more is required except to compile and run java.

Installation

Unzip the Eclipse IDE for Java EE Developers and double click the file named Eclipse.exe. You will probably want to create a link for it on your desktop. Once, it’s installed and launched you will have to select a workspace. Just accept the defaults and you will see the following:

image

Lets go ahead and write a simple program.

To write a "Hello World" program follow these steps:

  1. Start Eclipse.
  2. Create a new Java Project:
    1. File->New->Project.
    2. Select "Java" in the category list.
    3. Select "Java Project" in the project list. Click "Next".
    4. Enter a project name into the Project name field, for example, "HW Project".
    5. Click "Finish" Allow it to open the Java perspective
  3. Create a new Java class:
    1. Click the "Create a Java Class" button in the toolbar. (This is the icon below "Run" and "Window" with a tooltip that says "New Java Class.")
    2. Enter "HW" into the Name field.
    3. Click the checkbox indicating that you would like Eclipse to create a "public static void main(String[] args)" method.
    4. Click "Finish".
  4. A Java editor for HW.java will open. In the main method enter the following line.
         System.out.println("This is my first java program and btw Hello World");
  5. Save using ctrl-s. This automatically compiles HW.java.
  6. Click the "Run" button in the toolbar (looks like a VCR play button).
  7. You will be prompted to create a Launch configuration. Select "Java Application" and click "New".
  8. Click "Run" to run the Hello World program. The console will open and display "This is my first java program and btw Hello World".

You now have your first java program, lets go ahead and make an applet. Since you already have the HW.java open, click inside the window and remove all code. Now copy/paste the following code snippet.

Java Code Snippet for an applet.

   1: import java.applet.Applet;
   2: import java.awt.Graphics;
   3: import java.awt.Color;
   4:  
   5: @SuppressWarnings("serial")
   6: public class HelloWorld extends Applet{
   7:  
   8:   String text = "I'm a simple applet";
   9:  
  10:   public void init() {
  11:     text = "I'm a simple applet";
  12:     setBackground(Color.GREEN);
  13:   }
  14:  
  15:   public void start() {
  16:         System.out.println("starting...");
  17:   }
  18:  
  19:   public void stop() {
  20:         System.out.println("stopping...");
  21:   }
  22:  
  23:   public void destroy() {
  24:         System.out.println("preparing to unload...");
  25:   }
  26:  
  27:    public void paint(Graphics g){
  28:     System.out.println("Paint");
  29:     g.setColor(Color.blue);
  30:     g.drawRect(0, 0,
  31:            getSize().width -1,
  32:            getSize().height -1);
  33:     g.setColor(Color.black);
  34:     g.drawString(text, 15, 25);
  35:    }
  36: }

The Eclipse IDE should look like

image

Click "Run" to run the Hello World applet. Now, lets test our new java applet. So, navigate over to your workspace for example:

“C:\Users\mbcrump\workspace\HW Project\bin” and you should see 2 files.

HW.class
java.policy.applet

Create a HTML page with the following code:

   1: <HTML>
   2: <BODY>
   3: <APPLET CODE=HW.class WIDTH=200 HEIGHT=100>
   4: </APPLET>
   5: </BODY>
   6: </HTML>

Open, the HTML page in Firefox or IE and you will see your applet running. 

image

I hope this brief look at the Eclipse IDE helps someone get acquainted with Java Development. Even if your full time gig is with .NET, it will not hurt to have another language in your tool belt.

As always, I welcome any suggestions or comments.

Posted On Wednesday, May 19, 2010 8:38 AM | Feedback (1)
Office 2010 Professional Plus (Top 10 reasons to upgrade)

Being a huge nerd, I decided that I would go ahead and upgrade to the latest and greatest office. That being, Office 2010 Professional Plus. The biggest concern that I had was loosing all my mail settings from Outlook 2007. Thankfully, it upgrade gracefully and worked like a charm. So lets start this top 10 list.

1) You can upgrade without fear of loosing all your stuff! As you can tell by the screenshot below, you can select what you want to do. I selected to remove all previous versions. 

image 

2) Outlook conversations: Just like GMail, you can now group emails by conversations. This is simply awesome and a must have.

image

3) The ability to ignore conversations. If you are on a email thread that has nothing to do with you. Simply “ignore” the conversation and all emails go into the deleted folder.

image

4) Quick Steps, do you send an email to the same team member or group constantly. With quick steps, its just one click away.

image

5) Spell check in the Subject line!

image

6)  Easier Screenshots, built in just click the button. No more ALT-Printscreen for those that are not aware of the awesome SnagIT 10 that's out.

image

7) Open in protected view. When you open a document from an email attachment, it lets you know the file may be unsafe. You can click a button to enable editing. This is great for preventing macros.

 

 

 

image

8) Excel has always had a variety of charts and graphs available to visually depict data and trends. With Excel 2010, though, Microsoft has added a new feature called Sparklines, which allows you to place a mini-graph or trend line in a single cell.

The Sparklines are a cool way to quickly and simply add a visual element without having to go through the effort of inserting a graph or chart that overwhelms the worksheet.

image

9) Contact actions. If you hover over a name in the form or fields on an email, you get a popup giving you several actions you can perform on the person such as adding them to your Outlook contacts, scheduling a meeting, viewing their stored contact information if they are already in your contacts, sending an instant message or even starting a telephone call.

image

10) Windows 7 Task Bar Context Menu – I love the jumplist. I don’t know how much that I would actually use it but it just rocks.

image

Posted On Monday, May 17, 2010 9:47 PM | Feedback (2)
With a little effort you can “SEMI”-protect your C# assemblies with obfuscation.

This method will not protect your assemblies from a experienced hacker. It will however work with your everyday .net or silverlight projects. Everyday we see new keygens, cracks, serials being released that contain ways around copy protection from small companies. This is a simple process that will make a lot of hackers quit because so many others use nothing. If you were a thief would you pick the house that has security signs and an alarm or one that has nothing?

To so begin:

Obfuscation is the concealment of meaning in communication, making it confusing and harder to interpret. Lets begin by looking at the cartoon below:

 

image

 

You are probably familiar with the term and probably ignored this like most programmers ignore user security. Today, I’m going to show you reflection and a way to obfuscate it. Please understand that I am aware of ways around this, but I believe some security is better than no security. 

In this sample program below, the code appears exactly as it does in Visual Studio. When the program runs, you get either a true or false in a console window.

Sample Program.
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4.  
  5. namespace ObfuscateMe
  6. {
  7.     class Program
  8.     {
  9.       
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             Console.WriteLine(IsProcessOpen("notepad")); //Returns a True or False depending if you have notepad running.
  14.             Console.ReadLine();
  15.         }
  16.  
  17.  
  18.         public static bool IsProcessOpen(string name)
  19.         {
  20.             return Process.GetProcesses().Any(clsProcess => clsProcess.ProcessName.Contains(name));
  21.         }
  22.     }
  23. }

 

Pretend, that this is a commercial application. The hacker will only have the executable and maybe a few config files, etc. After reviewing the executable, he can determine if it was produced in .NET by examing the file in ILDASM or Redgate’s Reflector.

We are going to examine the file using RedGate’s Reflector. Upon launch, we simply drag/drop the exe over to the application. We have the following for the Main method:

 

image

and for the IsProcessOpen method:

 

image

 

Without any other knowledge as to how this works, the hacker could export the exe and get vs project build or copy this code in and our application would run.

Using Reflector output.
  1. using System;
  2. using System.Diagnostics;
  3. using System.Linq;
  4.  
  5. namespace ObfuscateMe
  6. {
  7.     class Program
  8.     {
  9.       
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             Console.WriteLine(IsProcessOpen("notepad"));
  14.             Console.ReadLine();
  15.         }
  16.  
  17.  
  18.         public static bool IsProcessOpen(string name)
  19.         {
  20.             return Process.GetProcesses().Any<Process>(delegate(Process clsProcess)
  21.             {
  22.                 return clsProcess.ProcessName.Contains(name);
  23.             });
  24.         }
  25.  
  26.     }
  27. }

The code is not identical, but returns the same value. At this point, with a little bit of effort you could prevent the hacker from reverse engineering your code so quickly by using Eazfuscator.NET. Eazfuscator.NET is just one of many programs built for this. Visual Studio ships with a community version of Dotfoscutor.

So download and load Eazfuscator.NET and drag/drop your exectuable/project into the window. It will work for a few minutes depending if you have a quad-core or not.

image image

After it finishes, open the executable in RedGate Reflector and you will get the following:

Main After Obfuscation

image

IsProcessOpen Method after obfuscation:

image

As you can see with the jumbled characters, it is not as easy as the first example. I am aware of methods around this, but it takes more effort and unless the hacker is up for the challenge, they will just pick another program. This is also helpful if you are a consultant and make clients pay a yearly license fee. This would prevent the average software developer from jumping into your security routine after you have left. I hope this article helped someone. If you have any feedback, please leave it in the comments below.

Posted On Sunday, May 16, 2010 2:43 PM | Feedback (2)
Tag Cloud