Archive for category .net

C# OCR Library


Download URL:


1. Remember to download the 2.0 tessdata (tesseract-2.00.eng.tar.gz) instead of the one for 3.0

2. The image size has to be larger, otherwise it will always show result (Confidence: 100 ; Word : “~”)

3. Copy the “tessdata” folder to the exe folder OR to hardcode the path in the program

No Comments

Recording HTTPS Traffic with JMeter’s Proxy Server & login

Recording HTTPS Traffic with JMeter’s Proxy Server _ BlazeMeter

JMeter Expert_ Testing performance of web page with Apache JMeter


Jmeter is an open source web performance testing tool.

The easiest way is to use “proxy” to record what you have done in browser, says firefox, and generate the script required.

For testing an based web application, below are important

  • Regular Expression Extractor to get the viewstate and eventvalidation value generated by (Web Form only; no need for MVC)
  • Adding Cookie Manager for storing cookie for


Regular Expression Extractors

Our first regular expression extractor will grab the page’s VIEWSTATE element and store it in the JMeterviewState variable. Add a new Regular Expression Extractor in JMeter by:

  1. Right click on your Thread Group
  2. Choose Add -> Post Processors -> Regular Expression Extractor
  3. Configure as follows
    • Reference Name: viewState
    • Regular Expression: name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)"
    • Template: $1$
    • Math No: 1
    • Default Value: ERROR

VIEWSTATE Regular Expression Extractor

We also need to include a regex extractor that stores the EVENTVALIDATION element in the eventValidationvariable. Again:

  1. Right click on your Thread Group
  2. Choose Add -> Post Processors -> Regular Expression Extractor
  3. Configure as follows
    • Reference Name: eventValidation
    • Regular Expression: name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)"
    • Template: $1$
    • Math No: 1
    • Default Value: ERROR

EVENTVALIDATION Regular Expression Extractor

Using the Extracted Values

Now that we have populated the viewState and eventValidation values, we need to include them when we POST to our application. In my run, this only happened on the login page.

  1. Select your login page POST in the Test Plan’s Recording Controller
  2. Set the __VIEWSTATE parameter to ${viewState}
  3. Set the __EVENTVALIDATION parameter to ${eventValidation}

Login POST Configuration

HTTP Cookie Manager

If you run your test plan now, you will see that it is still not working. This is because ASP.NET WebForms uses a cookie to store the login session. We can solve this with JMeter’s “HTTP Cookie Manager”.

  1. Right click on your Thread Group
  2. Choose Add -> Config Element -> HTTP Cookie Manager

Finally, run your Test Plan. You should see that your WebForms application returns the correct responses to JMeter’s requests. If not, double check that you are using the viewState and eventValidation variables in your login page POST (or any other post, for that matter) and that you have added the Cookie Manager.

Bonus – Parameterize Credentials Across Threads

Application performance for multiple concurrent logins with the same user is probably not a very interesting test case for your system. Luckily, it is extremely easy to parameterize login credentials for JMeter threads with a “CSV Data Set Config” element.

Store Credentials in CSV File

  1. Create a text file named credentials.csv in the same directory as your Test Plan .jmx file
  2. Populate credentials.csv with the login credentials you want to use (mind extra spaces)

Add CSV Data Set Config

  1. Select your Thread Group
  2. Choose Add -> Config Element -> CSV Data Set Config
  3. Configure as follows
    • Filename: credentials.csv
    • Variable Names: username,password

CSV Data Set Config

Use Variable Credentials in Login Post

  1. Select your login page POST in the Test Plan’s Recording Controller
  2. Configure as follows
    • <Your Login Element ID> : ${username}
    • <Your Password Element ID> : ${password}

Login POST Configuration with username, password Variables

Now the threads in your Test Plan will cycle through the credentials specified in your CSV.


The following articles were extremely helpful in figuring all of this out:



No Comments

Sample VBA for looping thru rows and copying data

Sub CopyData()
Dim iLastRow As Integer
Dim Rng As Range
iLastRow = Cells(Rows.Count, “K”).End(xlUp).Row
Dim ws1 As Worksheet
Set ws1 = Sheets(“Worksheet”)

Dim lastPo As String
Dim lastPoLine As String
Dim lastStyle As String
Dim lastDim As String
For i = 1 To iLastRow

‘handle style
If Not IsEmpty(ws1.Cells(i, “D”).Value) Then
lastStyle = ws1.Cells(i, “D”).Value
ws1.Cells(i, “D”).Value = lastStyle
End If

‘handle values
If Not IsEmpty(ws1.Cells(i, “E”).Value) Then
lastPo = ws1.Cells(i, “E”).Value
lastPoLine = ws1.Cells(i, “F”).Value
lastDim = ws1.Cells(i, “G”).Value
ws1.Cells(i, “E”).Value = lastPo
ws1.Cells(i, “F”).Value = lastPoLine
ws1.Cells(i, “G”).Value = lastDim
End If
Next i

End Sub

No Comments

TFS Branching Guide


No Comments

Team Foundation Server

There are few useful features to keep control the source code, following are few methods may be used in different scenario.

For example, when the project is under construction, while the current production version of the project is required to bug fix, there are few approaches to cater the needs,

1. Multiple workspace with labeling different versions of source code

– The workspace acts as the local working folder. By creating creating 2 different workspaces, one can contain the version under construction (e.g. v2.0), and get back the historical version which is labeled before (e.g. v1.0).

– Once the bug is fixed (v1.1), then check-in back the changed source code to TFS, added back to v2.0 or create a new label called v2.1

This is useful for small team development, while only one to two developers will fix the bug within limited time period.


2. Branching

– Create another branched version at the same time

– Both version is actually kept track in TFS (server side) instead of client side mentioned above (workspace)

– The branched version have to be merged to mainstream version after completion

This supports many developers working on the branched version and the main version at the same time.


3. Shelves

– Shelve acts as a temp location in TFS for putting existing incomplete changes

– By putting the changes into the shelves, the file is “undo” to previous version, for testing or developing another feature


No Comments

Get Email Address from AD for Different Trusted Domains

public string GetADEmailAddress(string adFullUserName)
	if (!adFullUserName.Contains(@"\"))
		return string.Empty;

	// init var
	string domain = adFullUserName.Contains(@"\") ? adFullUserName.Substring(0, adFullUserName.IndexOf(@"\")) : null;
	string adusername = adFullUserName.Contains(@"\") ? adFullUserName.Substring(adFullUserName.IndexOf(@"\") + 1) : "";
	string adConnectionStringWithDomain = adConnectionString + "/CN=" + domain;

	DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain);
	DirectorySearcher dSearch = new DirectorySearcher(entry);
	dSearch.Filter = "(&(objectClass=user)(samAccountName=" + adusername + "))";

	SearchResult r = dSearch.FindOne();
	if (r != null)
		DirectoryEntry UserDirectoryEntry = r.GetDirectoryEntry();
		return UserDirectoryEntry.Properties["mail"].Value.ToString();

	return string.Empty;

No Comments performance monitoring / debuging

Performance Analysis of Logs (PAL) Tool

Analysis Performance Monitor Data

Debug Diagnostic Tool v1.2

Network Monitoring

Download and Install Debugging Tools for


No Comments

Error while creating Excel object

Microsoft Excel Application entry missing in DCOMCNFG

On 64 bit system with 32 bit Office try this:

  1. Start
  2. Run
  3. mmc -32
  4. File
  5. Add Remove Snap-in
  6. Component Services
  7. Add
  8. OK
  9. Console Root
  10. Component Services
  11. Computers
  12. My Computer
  13. DCOM Config
  14. Microsoft Excel Application

Error while creating Excel object
1. In DCOMCNFG, right click on the My Computer and select properties.
2. Choose the COM Securities tab
3. In Access Permissions, click “Edit Defaults” and add Network Service to it and give it “Allow local access” permission. Do the same for <Machine_name>\Users.
4. In launch and Activation Permissions, click “Edit Defaults” and add Network Service to it and give it “Local launch” and “Local Activation” permission. Do the same for <Machine_name>\Users


No Comments

Solution fails on 64 bit system with error “Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine” and “Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine”.

Install: Microsoft Access Database Engine 2010 Redistributable

** Probably may need to install the Access 2007 version **

If Offce 2003 (32 bits) already installed on the system, please

1. Remove the Office 2003 (32 bits)

2. Install above Access DB Engine (64bits)

3. Install back Office 2003 (32 bits)


No Comments

IDictionary : Using custom class as key

I was using IDictionary in one of my projects. The KeyClass is very simple containing just two integers.

public class KeyClass
    public int ValueA{get;set;}
    public int ValueB{get;set;}

I was accessing values from dictionary like follows:

var k = new KeyClass(1, 1);
var v = myDictionary[k];

The dictionary for sure contained KeyClass key with ValueA = 1 and ValueB = 1 and simillarly many other keys. But I got exception:

The given key is not present in the dictionary.
I implemented IComparable in class KeyClass but it did not solve my problem. I googled and found this CodeProject article. It describes following technique to use a class implementing IEqualityComparer interface. I defined it in my class:

public class KeyClass
    public int ValueA{get;set;}
    public int ValueB{get;set;}

    public class EqualityComparer : IEqualityComparer<KeyClass>
        public bool Equals(KeyClass a, KeyClass b)
            return a.ValueA == b.ValueA && a.ValueB == b.ValueB;

        public int GetHashCode(KeyClass k)
            return k.ValueA ^ k.ValueB;

Now I have to declare IDictionary as follows:

var d = new Dictionary<KeyClass, ValueClass>(new KeyClass.EqualityComparer());

Things worked fine afterwards.

No Comments