How to create a setup project for a Windows Service application in Visual C#

This article describes how to create a setup project for a Windows Service application (formerly named an “NT service”). To do this, you must first create a solution that contains a simple Windows Service project that writes an entry to its application log. You then add a setup project to the solution to install the Window Service. Finally, you start the service. You can start the service by using the Services item in the Administrative Tools folder in the Start menu.


The following list outlines the recommended hardware, software, network infrastructure, and service packs that you must have:

  • Microsoft Windows 2000, Windows XP, Windows Server 2003, or a later Microsoft operating system with the .NET Framework installed
  • Microsoft Visual Studio .NET Enterprise, Microsoft Visual Studio .NET Enterprise Architect, Microsoft Visual Studio 2005, or Microsoft Visual Studio 2008.

This article assumes that you are familiar with Windows Services. If you are not familiar with Windows Services, see the first reference in the REFERENCES section of this article.

This article also assumes that the user account that you use to install and to run this service has the permissions that you must have to install and to start services, and also has the permissions that you must have to access the event log.

Create a Setup Project for a Windows Service

This section describes how to create a Windows Service project, and how to use a compiled setup project to install the Windows Service.

Create a Windows Service Project

  1. Start Microsoft Visual Studio.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual C# Projects under Project Types, and then click Windows Service under Templates.Note In Visual Studio 2005 or Visual Studio 2008, expand Visual C# under Project Types, clickWindows, and then click Windows Service under Templates.
  4. Type LogWriterService in the Name text box, and then type C:\ in the Location text box. Click OK.
  5. In Solution Explorer, right-click Service1.cs, and then click View Code.
  6. In the OnStart event handler, replace the comments with the following code:
    EventLog.WriteEntry("My simple service started.");
  7. In Solution Explorer, double-click Service1.cs.
  8. In the Code Editor window, right-click Design View, and then click Properties
  9. In the Properties pane, click the Add Installer link.
  10. In the Properties pane for ServiceInstaller1, change the ServiceName property to Service1.
  11. In the Code Editor window in Design view, click ServiceProcessInstaller1.
  12. In the Properties pane, change the Account property to LocalSystem (The LocalService andNetworkService values are available only in Microsoft Windows XP).

Use a Compiled Setup Project to Install the Windows Service

After you complete the steps in the previous section to configure the Windows Service project, follow these steps to add a deployment project that packages the service application so that the service application can be installed:

  1. Add a new project to your LogWriterService project. To do this, follow these steps:
    1. In Solution Explorer, right-click Solution ‘LogWriterService’ (1 project), point to Add, and then click New Project.
    2. Click Setup and Deployment Projects under Project Types, and then click Setup Projectunder Templates.
    3. In the Name text box, type ServiceSetup.
    4. Type C:\ in the Location text box, and then click OK.
  2. Tell the deployment project what to package. To do this, follow these steps:
    1. In Solution Explorer, right-click ServiceSetup, point to Add, and then click Project Output
    2. In the Add Project Output Group dialog box, in the Project box, click LogWriterService
    3. Click Primary Output, and then click OK.
  3. For correct installation, add only primary output. To add the custom actions, follow these steps:
    1. In Solution Explorer, right-click ServiceSetup, point to View, and then click Custom Actions
    2. Right-click Custom Actions, and then click Add Custom Action.
    3. Click Application Folder, and then click OK.
    4. Click Primary output from LogWriterService (Active), and then click OK.Notice that Primary output appears under InstallCommitRollback and Uninstall.
  4. By default, setup projects are not included in the build configuration. To build the solution, use one of the following methods:
    • Method 1
      1. Right-click LogWriterService, and then click Build.
      2. Right-click ServiceSetup, and then click Build.
    • Method 2
      1. On the Build menu, click Configuration Manager to build the whole solution.
      2. Click to select the Build check box for ServiceSetup.
      3. Press F7 to build the whole solution. When the solution is built, you have a complete installation package that is available for the service.
  5. To install the newly built service, right-click ServiceSetup, and then click Install.
  6. In the ServiceSetup dialog box, click Next three times. Notice that a progress bar appears while the service installs.
  7. When the service is installed, click Close.

Complete Code Listing


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;

namespace LogWriterService
	public class Service1 : System.ServiceProcess.ServiceBase
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Service1()
			// The Windows.Forms Component Designer must have this call.

			// TODO: Add any initialization after the InitComponent call

		// The main entry point for the process
		static void Main()
			System.ServiceProcess.ServiceBase[] ServicesToRun;

			// More than one user service may run in the same process. To add
			// another service to this process, change the following line to
			// create a second service object. For example,
			//   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
			ServicesToRun = new System.ServiceProcess.ServiceBase[] { new Service1() };


		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
			components = new System.ComponentModel.Container();
			this.ServiceName = "Service1";

		/// <summary>
		/// Clean up any resources that are being used.
		/// </summary>
		protected override void Dispose( bool disposing )
			if( disposing )
				if (components != null) 
			base.Dispose( disposing );

		/// <summary>
		/// Set things in motion so your service can do its work.
		/// </summary>
		protected override void OnStart(string[] args)
			EventLog.WriteEntry("My simple service started.");

		/// <summary>
		/// Stop this service.
		/// </summary>
		protected override void OnStop()
			// TODO: Add code here to perform any tear-down necessary to stop your service.

Verify That It Works

  1. In Control Panel, double-click Administrative Tools, and then double-click Services
  2. Right-click Service1, and then click Start
  3. Use one of the following methods to verify that an event is logged in the event log:
    • Method 1
      1. In Control Panel, double-click Administrative Tools, and then double-click Event Viewer.
      2. Click Application Log in the left pane, and then locate the event log for your service from the right pane.
    • Method 2
      1. In Server Explorer, expand Servers, expand ComputerName, expand Event Logs, expand Application, and then expand Service1. Recall that Service1 is the name of the class, not the service itself. Therefore, Service1 is used as the application name. (It is beyond the scope of this article to explain how to customize the names.)
      2. Move the cursor over the log entries. The second entry from the top should read “My simple service started”.

Referenced by:

10 Tips to Improve your LINQ to SQL Application Performance

Hey there, back again. In my first post about LINQ I tried to provide a brief(okay, bit detailed) introduction for those who want to get involved with LINQ to SQL. In that post I promised to write about a basic integration of WCF and LINQ to SQL working together, but this is not that post.

Since LINQ to SQL is a code generator and an ORM and it offers a lot of things, it is normal to be suspicious about performance of it. These are right up to a certain point as LINQ comes with its own penalties. But there are several benchmarks showing that DLINQ brings us up to %93 of the ADO.NET SQL DataReader performance if optimizations are done correctly.

Hence I summed up 10 important points for me that needs to be considered during tuning your LINQ to SQL’s data retrieval and data modifying process:

1 – Turn off ObjectTrackingEnabled Property of Data Context If Not Necessary

If you are trying only to retrieve data as read only, and not modifying anything, you don’t need object tracking. So turn it off using it like in the example below:

using (NorthwindDataContext context = new NorthwindDataContext())
  context.ObjectTrackingEnabled = false;

This will allow you to turn off the unnecessary identity management of the objects – hence Data Context will not have to store them because it will be sure that there will be no change statements to generate.

2 – Do NOT Dump All Your DB Objects into One Single DataContext

DataContext represents a single unit of work, not all your database. If you have several database objects that are not connected, or they are not used at all (log tables, objects used by batch processes,etc..). These objects just unnecessarily consume space in the memory hence increasing the identity management and object tracking costs in CUD engine of the DataContext.

Instead think of separating your workspace into several DataContexts where each one represents a single unit of work associated with it. You can still configure them to use the same connection via its constructors to not to loose the benefit of connection pooling.

3 – Use CompiledQuery Wherever Needed

When creating and executing your query, there are several steps for generating the appropriate SQL from the expression, just to name some important of them:

  1. Create expression tree

  2. Convert it to SQL

  3. Run the query

  4. Retrieve the data

  5. Convert it to the objects

As you may notice, when you are using the same query over and over, hence first and second steps are just wasting time. This is where this tiny class in System.Data.Linq namespace achieves a lot. With CompiledQuery, you compile your query once and store it somewhere for later usage. This is achieved by static CompiledQuery.Compile method.

Below is a Code Snippet for an example usage:

Func<NorthwindDataContext, IEnumerable<Category>> func =
CompiledQuery.Compile<NorthwindDataContext, IEnumerable<Category>>
   ((NorthwindDataContext context) => context.Categories.
      Where<Category>(cat => cat.Products.Count > 5));

And now, “func” is my compiled query. It will only be compiled once when it is first run. We can now store it in a static utility class as follows :

/// <summary>
/// Utility class to store compiled queries
/// </summary>
public static class QueriesUtility
/// <summary>
  /// Gets the query that returns categories with more than five products.
  /// </summary>
  /// <value>The query containing categories with more than five products.</value>
  public static Func<NorthwindDataContext, IEnumerable<Category>>
        Func<NorthwindDataContext, IEnumerable<Category>> func =
          CompiledQuery.Compile<NorthwindDataContext, IEnumerable<Category>>
          ((NorthwindDataContext context) => context.Categories.
            Where<Category>(cat => cat.Products.Count > 5));
        return func;

And we can use this compiled query (since it is now a nothing but a strongly typed function for us) very easily as follows:

using (NorthwindDataContext context = new NorthwindDataContext())

Storing and using it in this way also reduces the cost of doing a virtual call that’s done each time you access the collection – actually it is decreased to 1 call. If you don’t call the query don’t worry about compilation too, since it will be compiled whenever the query is first executed.

4 – Filter Data Down to What You Need Using DataLoadOptions.AssociateWith

When we retrieve data with Load or LoadWith we are assuming that we want to retrieve all the associated data those are bound with the primary key (and object id). But in most cases we likely need additional filtering to this. Here is whereDataLoadOptions.AssociateWith generic method comes very handy. This method takes the criteria to load the data as a parameter and applies it to the query – so you get only the data that you need.

The following code below associates and retrieves the categories only with continuing products:

using (NorthwindDataContext context = new NorthwindDataContext())
DataLoadOptions options = new DataLoadOptions();
  options.AssociateWith<Category>(cat=> cat.Products.Where<Product>(prod => !prod.Discontinued));
  context.LoadOptions = options;

5 – Turn Optimistic Concurrency Off Unless You Need It

LINQ to SQL comes with out of the box Optimistic Concurrency support with SQL timestamp columns which are mapped to Binarytype. You can turn this feature on and off in both mapping file and attributes for the properties. If your application can afford running on “last update wins” basis, then doing an extra update check is just a waste.

UpdateCheck.Never is used to turn optimistic concurrency off in LINQ to SQL.

Here is an example of turning optimistic concurrency off implemented as attribute level mapping:

[Column(Storage=“_Description”, DbType=“NText”,
public string Description
    return this._Description;
    if ((this._Description != value))
      this._Description = value;

6 – Constantly Monitor Queries Generated by the DataContext and Analyze the Data You Retrieve

As your query is generated on the fly, there is this possibility that you may not be aware of additional columns or extra data that is retrieved behind the scenes. Use Data Context’s Log property to be able to see what SQL are being run by the Data Context. An example is as follows:

using (NorthwindDataContext context = new NorthwindDataContext())
  context.Log = Console.Out;

Using this snippet while debugging you can see the generated SQL statements in the Output Window in Visual Studio and spot performance leaks by analyzing them. Don’t forget to comment that line out for production systems as it may create a bit of an overhead. (Wouldn’t it be great if this was configurable in the config file?)

To see your DLINQ expressions in a SQL statement manner one can use SQL Query Visualizer which needs to be installed separately from Visual Studio 2008.

7 – Avoid Unnecessary Attaches to Tables in the Context

Since Object Tracking is a great mechanism, nothing comes for free. When you  Attach an object to your context, you mean that this object was disconnected for a while and now you now want to get it back in the game. DataContext then marks it as an object that potentially will change – and this is just fine when you really intent to do that.

But there might be some circumstances that aren’t very obvious, and may lead you to attach objects that arent changed. One of such cases is doing an AttachAll for collections and not checking if the object is changed or not. For a better performance, you should check that if you are attaching ONLY the objects in the collection those are changed.

I will provide a sample code for this soon.

8 – Be Careful of Entity Identity Management Overhead

During working with a non-read only context, the objects are still being tracked – so be aware that non intuitive scenarios this can cause while you proceed. Consider the following DLINQ code:

using (NorthwindDataContext context = new NorthwindDataContext())
var a = from c in context.Categories
  select c;

Very plain, basic DLINQ isn’t it? That’s true; there doesn’t seem any bad thing in the above code. Now let’s see the code below:

using (NorthwindDataContext context = new NorthwindDataContext())
var a = from c in context.Categories
  select new Category
    CategoryID = c.CategoryID,
    CategoryName = c.CategoryName,
    Description = c.Description

The intuition is to expect that the second query will work slower than the first one, which is WRONG. It is actually much faster than the first one.

The reason for this is in the first query, for each row the objects need to be stored, since there is a possibility that you still can change them. But in the 2nd one, you are throwing that object away and creating a new one, which is more efficient.

9 – Retrieve Only the Number of Records You Need

When you are binding to a data grid, and doing paging – consider the easy to use methods that LINQ to SQL provides. These are mainly Take and Skip methods. The code snippet involves a method which retrieves enough products for a ListView with paging enabled:

/// <summary>
/// Gets the products page by page.
/// </summary>
/// <param name=”startingPageIndex”>Index of the starting page.</param>
/// <param name=”pageSize”>Size of the page.</param>
/// <returns>The list of products in the specified page</returns>
private IList<Product> GetProducts(int startingPageIndex, int pageSize)
using (NorthwindDataContext context = new NorthwindDataContext())
    return context.Products
           .Skip<Product>(startingPageIndex * pageSize)

10 – Don’t Misuse CompiledQuery

I can hear you saying “What? Are you kiddin’ me? How can such a class like this be misused?”

Well, as it applies to all optimization LINQ to SQL is no exception:

“Premature optimization is root all of evil” – Donald Knuth

If you are using CompiledQuery make sure that you are using it more than once as it is more costly than normal querying for the first time. But why?

That’s because the resulting function coming as a CompiledQuery is an object, having the SQL statement and the delegate to apply it. It is not compiled like the way regular expressions are compiled. And your delegate has the ability to replace the variables (or parameters) in the resulting query.

That’s the end folks, I hope you’ll enjoy these tips while programming with LINQ to SQL. Any comments or questions via sidarok at sidarok dot com or here to this post are welcome.

Referenced by:

Barcode Image Generation Library

Posted by:  Brad Barnhill



This article and its code provides a way for developers to put barcodes into their applications. It allows for the generation of barcode images without the use of “barcode fonts”. This need arose out of the necessity for one of my own projects to use barcodes and the lack of free libraries on the web to do the job.

To give an idea of what happens in this library: it first turns the data into a series of 1s and 0s representing equal-width bars and spaces. This string of binary information is then sent to a drawing function that converts it to an image representing the desired barcode. This approach allows for one common drawing method to be used on all symbologies.

Supported Encoding Types

Code 128 Code11 Code 39 (Extended / Full ASCII)
Code 93 EAN-8 EAN-13
MSI ISBN Standard 2 of 5
Interleaved 2 of 5 PostNet UPC Supplemental 2
UPC Supplemental 5 Codabar ITF-14
Telepen FIM (Facing Identification Mark)

** Keep in mind that some symbologies go by more than one name, so make sure the one you are using isn’t listed above by a different name before contacting me to add it. If it isn’t listed above and you would like me to look at adding it to this library, please post a comment below, and I will take a look at it as soon as possible. (Bugs are always a priority, so please send me bug reports.)

Using the Code

The library contains a class called BarcodeLib. There are three constructors:

 Collapse | Copy Code
Barcode (string, BarcodeLib.TYPE);

If you decide to create an instance with parameters, the parameters are as follows: the string is the data to be encoded into the barcode, and BarcodeLib.TYPE is the symbology to encode the data with. If you do not choose to specify the data and type at the time the instance is created, you may specify them through the appropriate property later on (but before you encode).

 Collapse | Copy Code
BarCodeLib.Barcode b = new BarCodeLib.Barcode(BarCodeLib.TYPE.UPCA, 
          "038000356216", Color.Black, Color.White, 300, 150);

To get the image representing the data generated, you must then call one of the many Encode functions.

 Collapse | Copy Code
public Image Encode(TYPE iType, string StringToEncode, int Width, int Height)
public Image Encode(TYPE iType, string StringToEncode, 
        Color ForeColor, Color BackColor, int Width, int Height)
public Image Encode(TYPE iType, string StringToEncode, Color ForeColor, Color BackColor)
public Image Encode(TYPE iType, string StringToEncode)
Encode(TYPE iType)

The resulting Image contains the barcode in image format. More functionality has been added, so you can save theImage once it is encoded.

 Collapse | Copy Code
public void SaveImage(string Filename, SaveTypes FileType)

This function can be used by specifying the full path (filename included) of the location you would like to save the image to as a string. The second parameter is an enumerator (BarcodeLib.SaveTypes) that represents the supported types (JPG, BMP, PNG, GIF, TIFF) of files you can save. Functionality has been added so that you can now set the IncludeLabel parameter to allow it to draw the data that’s encoded in the barcode, below the image, as a label. Keep in mind that this will take up some of the space you specify for the size of the image.

 Collapse | Copy Code
b.IncludeLabel = true;

This is used to put the data encoded at the bottom of the image. If you do not set this parameter, it will just generate the barcode without the data at the bottom.

Points of Interest

Writing this library offered me the chance to become intimately familiar with how barcode symbologies work and how the symbologies differ from one another.

A new property has been added to allow exportation of the image and properties in XML format. Keep in mind that thebarcode must be encoded first before this property is read; otherwise, an error will be thrown to notify you of this mistake.

 Collapse | Copy Code


    • October 10, 2007
      • Initial release (bugs most certainly exist, and a couple of symbologies need to be modified/implemented).
    • October 16, 2007
      • Updated Encode_Code39() to fix a bug that didn’t include inter-character spaces.
      • Also, updated the function Generate_Image(Color, Color), and replaced the section usingSetPixel with the following:
 Collapse | Copy Code
using (Graphics g = Graphics.FromImage(b))
    g.DrawLine(new Pen(c), x, 0, x, b.Height);
    g.DrawLine(new Pen(c), x + 1, 0, x + 1, b.Height);
    • October 17, 2007
      • Changed the Generate_Image(Color, Color) function again to be a little more efficient. Instead of drawing two lines, it just uses a 2px-wide pen now.
 Collapse | Copy Code
using (Graphics g = Graphics.FromImage(b))
    g.DrawLine(new Pen(c, (float)2), new Point(x, 0),
    new Point(x, b.Height));
      • Added the ability to call BarcodeLib.Generate_Labels(Image), it will add the label showing the data encoded at the bottom of the barcode.
      • Fixed a bug in the Test application where, if you encoded with PostNet as the type, it would automatically try to put the label at the bottom and labels aren’t available on PostNet images. This caused it to throw an error that a try{}catch{} can handle for now. 
      • Took c0ax_lx’s advice and moved…
         Collapse | Copy Code
        using (Graphics g = Graphics.FromImage(b))

        … outside the while loop to improve resource usage.

    • October 26, 2007
      • Article edited and moved to the main CodeProject article base.
    • November 1, 2007
      • Complete restructuring of the library to abstract portions of it. Should be much cleaner to look at.
      • An interface was added to force any updates to adhere to the structure.
      • There were some bugs that were fixed in this release.
      • Some of the encoding types on the menu were encoding with a different type than they said.
      • Changed CheckNumericOnly() to be one line of code instead of a massive O^2 complicated take. (Thanks, Pete!)
    • December 9, 2007
      • Bug fixed in UPC-E encoding that would cause an index-out-of-range exception to be thrown. (Thanks Luca Z.)
 Collapse | Copy Code
int pos = 0;
      • This library is getting better with the help of people like Luca and Pete. Keep up the good work, friends.
    • April 16, 2008
      • Code 128 support (beta) (the FNC* chars are still not encoding right… I have to figure that out), but … it’s at least here for your trial and for your comments.
      • Also, there were a few country codes left out of the EAN-13 assigning country lookup. I added what I could find that I left out.
      • Changed the CheckNumericOnly() back to a more complex task because some data being encoded was longer than what Int64.TryParse(string, out) could handle … so back to a more complex, but still a faster, task than comparing each char. Now, I break the string into pieces and test each piece.
    • May 3, 2008
      • Code 128 had some bug fixes added.
      • One was present in InsertStartandCodeCharacters().
      • Bug fixed when trying to encode an apostrophe, it needed an escape character when selecting the data for it from the dataset.
    • May 27, 2008
      • PostNet now supports 5, 6, 9, 11 digit data.
      • Also, a bug with the check-digit for PostNet is fixed.
      • Code 128 now supports specifying and locking the encoding to a specific type (Code A, B, C).
      • Code 39 Extended (Full ASCII) is now supported.
    • May 29, 2008
      • Bug fixed (thanks in Bitmap Generate_Image(Color DrawColor, Color BackColor)that caused the drawing to be off by one horizontal pixel. This caused the drawing to cut 1 pixel width off the first bar that was drawn if it was drawn up against the edge of the image.
      • The drawing function also changed a bit to eliminate the variable int x; from the function.
      • All positions are now calculated off the variable int pos;, which cuts out one unnecessary and confusing variable.
    • July 30, 2008
      • Bug fixed (thanks Kazna4ey and WolfgangRoth) in init_Code128() that caused .Select(string filterExpression) to return the wrong rows due to case insensitivity. So, the following was added:
 Collapse | Copy Code
this.C128_Code.CaseSensitive = true;
      • Another function byte[] GetImageData(SaveTypes savetype) was added so that users may request the bytes of the image easily. (Useful if using Crystal Reports, etc.)
    • August 26, 2008
      • Bug fixed (thanks JackyWu2005) in Code128.cs that was preventing the proper start characters from being inserted. This only happened when switching back to A from any other encoding type.
    • October 20, 2008
      • Added ITF-14 and Code93.
      • Fixed a bug in Save As functionality that was not saving files in the selected format.
      • Labels now show checksums except in C128 and C11.
    • December 3, 2008
      • Can now specify image size before encoding.
      • Complete overhaul of the drawing function to allow for dynamic drawing size. Now calculates the bar width based on the specified image size. Removed resize functions due to inaccuracy of the resizing method. The encoding functions have been revamped to reflect these changes (removed some of the overloaded functions referencing the resize functions). Also removed a majority of the


         statements from


         to simplify it. Updated the article to reflect the changes to the


      functions and the changes to the drawing functions.
  • February 11, 2009
    • Fixed bug in Code 128C that would not insert a 0 in front of an odd length string of raw data.
    • Fixed a bug (thanks Shaihan Murshed) in Code 39 that let the user encode * in the string of data. This should only be used for starting characters, and is now handled.
    • Fixed a bug in Code 39 that was inserting an extra 0 at the end of the encoded string. This did not affect the validity of the barcodes, it was just not supposed to be there.
    • Added a new property to the library called FormattedData. This value is what is actually encoded. It is formatted for certain types of barcodes, for example, Code 39 requires * in front and behind thebarcode.
  • June 4, 2009 (
    • Fixed a bug in Code128-A and Code128-B that would cause it to encode incorrectly due to incorrectly trying to compact the barcode for Code128-C. This functionality is now bypassed if Code128-A or Code128-B is selected.
    • Removed a useless variable bEncoded from BarcodeLib.cs.
    • static methods now support generating the data label (required addition of a parameter to 3 of the 5static methods used to encode).
    • Property now available to retrieve the amount of time (EncodingTime) it took to encode and generate the image. (Might be helpful for diagnostics.)
    • Modified a few error messages to be more descriptive about correcting the problem with data length.
    • The Barcode class now inherits from IDisposable – XML export functionality added to BarcodeLib to allow the data, encoded data, and other properties to be exported in XML along with the image inBase64String format. This includes functionality to GetXML() andGetImageFromXML(BarcodeXML).
    • To go along with the XML functionality, there is now a dataset included that has the basic layout of the XML data to make importing and exporting easy.
    • ImageFormat is now a property to set to select what type of image you want returned (JPEG is default). This can help speed of transferring data if using a Web Service.
    • ITF-14 now draws the label with the proper background color instead of always being white.
  • August 16, 2009 (
    • Fixed a bug that allowed non-numeric data to be encoded with Code128-C, a check has been put in place to handle this. It throws an error EC128-6 now, if found to contain something that isn’t in Code128-C.
    • Fixed a bug in GetEncoding() for C128. This would allow Code128-B to switch and dynamically use Code128-A if it couldn’t find a char in its set.
  • November 2, 2009 (
    • Changed the use of a Pen object that was not disposed of. This was not causing a problem, just bad technique.
    • Fixed an encoding issue with C128-B that had a wrong character in its encoding set at one point (U instead of Z in codeset B).
  • January 4, 2010 (
    • The UPC-A check digit is now calculated every time whether 11 or 12 digits are passed in. If 12 is passed in and it has got an incorrect check digit, then it is replaced with the correct check digit. This prevents an unscannable barcode from being generated.
    • The EAN13 check digit is now calculated every time whether 12 or 13 digits are passed in. If 13 is passed in and it has got an incorrect check digit, then it is replaced with the correct check digit. This prevents an unscannable barcode from being generated.
    • All errors can be accessed via the BarcodeLib.Errors properties which is a list of separate errors encountered.
    • All symbologies were moved to the BarcodeLib.Symbologies namespace for better organization.
    • The FormattedData property was not being used, so it was removed.
    • The Version property was added to BarcodeLib to allow reading the libraries version number.
  • April 28, 2010 (
    • Fixed a bug in Code 39 extended that was erasing the start and stop characters if extended was used.
    • Fixed a bug that if barcodes were aligned left or right, they would cut off a part of the starting or ending bar, which was a drawing bug that’s been present since
    • Fixed a bug in Code 128C that checked for numeric data; if it was bigger than Int64 and was numeric, it would throw an exception saying it was non-numeric data.
    • Fixed a bug in UPC-A that encoded with the same sets as EAN-13 and only CodeA and CodeC should have been used.
    • Made the Version property static so it can be read without creating an instance.
    • Added a LabelFont property to allow the labels font to be changed.
    • Restructured the label drawing functions to take font height and use that to determine the height of the label.
    • Created an IsNumeric function in C128-C to better separate that functionality. Replaced Int64 withInt32 to better allow compatibility with x86 processors.
    • EncodingTime now includes the time to draw the image and not just the encoding.
    • Alignment property added to allow aligning the barcode in the image given if the image space is wider than the drawn barcode. (Default is centered.)
    • Postnet drawing is incorporated into the default drawing case now, which shortens the code and gets rid of some redundant code.
    • Telepen symbology added.
  • July 18, 2010 (
    • Fixed a bug in Code 93 that caused four characters to be encoded incorrectly.
    • Fixed a bug where the ITF-14 bearer bars were not drawing evenly.
    • Fixed a bug in Codabar that would report an object not set to a reference error if non-numeric is found.
    • Added property LabelPosition to position label above or below the barcode, and align the label left, right, or center.
    • Added property RotateFlipType to allow rotation/flipping the image before it is returned.
    • Added several of the newer properties to the XML output of GetXML().
    • Removed Codabar start / stop characters in the label.
    • IsNumeric function added to BarcodeCommon so that every symbology has access to it.
  • June 16, 2011 (
    • Fixed a bug in drawing of barcodes that caused barcodes to be cut off on the left and right when aligned to the sides.
    • Fixed a bug in the project where the BarcodeXML dataset was corrupt.
    • Added the GetSizeOfImage function that returns the real world coordinates of the EncodedImage.
    • Facing Identification Mark(FIM) symbology added.