How to make assembly strongname and install DLL in GAC

September 25, 2009

Steps to make assembly strong name(SN) to DLL:

  1. Open .net command prompt.
  2. Go to the folder contanig DLL.
  3. Type sn -k test.snk, you can use any file name instead of test. This will create  test .snk file in that folder.
  4. Open the assemblyinfo.cs file of project.
  5. Type file path  in this tag [assembly:AssemblyKeyFile@”E:\hemant\practice\HP\bin\Debug\HP.snk”)]
  6. Build the applications, finally your strong name created for your DLL.


  • Created class library path E:\hemant\practice\HP
  • Open command prompt go to Dll folder path.

  • Type sn -k HP.snk

This create  HP.snk file in E:\hemant\practice\HP\bin\Debug folder.

  • Open the  AssemblyInfo.cs file of project. Type  path  of snk file in following attribue.

  • Build class library.

Steps for  Installing  in GAC

  • After giving strong name in .net command prompt type gacutil in DLL path

this will install file in assembly.

  • Copy the DLL file C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 folder.

  • You can add references  to another  project  using .net tab.

LINQ: What is the purpose of var ?

August 26, 2009

If you’ve never heard of var, var is a new way to declare variables in C# 3.0 that uses implicit typing. Let’s show a quick couple of examples.

Before 3.0
string myString = “hello”;
int myInt = 5;
float myFloat = 5.5f;

After 3.0
var myString = “hello”;
var myInt = 5;
var myFloat = 5.5f;

The distinction here is that var is not the same as object, or the JavaScript “var” data type as it’s actually strongly typed, but inferred from whatever the value is being assigned.

Create your own types with var
The big reason for var in my opinion is that LINQ enables you to create or “project” wholly new data types without having to create the type themselves. This is known as projection.

string[] aBunchOfWords = {“One”,“Two”“Hello”“World”,“Four”“Five”};

Let’s look at a sample query :

 var result = fromin aBunchOfWords
              where s.Length == 5
              select s;

In this example, I am projecting the string “s”,  so I could have easily replaced var with the type IEnumerable<string> as shown in bold below and my code would have worked fine.


IEnumerable<string> result =
fromin aBunchOfWords
where s.Length == 5
select s;
But what if I wanted to project something more complex, like a type that contains
1) the string
2) the length of the string as an integer
3) the first three characters of the substring


Using the power of var, this is pretty easy as shown in bold below:

var result =
fromin aBunchOfWords
where s.Length == 5
//Creates a new anonymous type with name/value pairs
new {Value=s, Length=s.Length, FirstThreeLetters=s.Substring(0,3)};

//Print values
(varin result)
Console.WriteLine(“Value: {0}, Length:{1}, SubString:{2}”,
x.Value, x.Length, x.FirstThreeLetters);

This prints:
Value: Hello, Length:5, SubString:Hel
Value: World, Length:5, SubString:Wor

Difference between BlackBox and whiteBox Testing

July 15, 2009
BlackBox Testing:
Also known as functional testing. A software testing technique whereby the internal workings of the item being tested are not known by the tester. For example, in a black box test on a  software design the tester only knows the inputs and what the expected outcomes should be and not how the program arrives at those outputs. The tester does not ever examine the programming code and does not need any further knowledge of the program other than its specifications.  The advantages of this type of testing include:
  • The test is unbiased because the designer and the tester are independent of each other.
  • The tester does not need knowledge of any specific programming languages.
  • The test is done from the point of view of the user, not the designer.
  • Test cases can be designed as soon as the specifications are complete.

 The disadvantages of this type of testing include:

  • The test can be redundant if the software designer has already run a test case.
  • The test cases are difficult to design.
  • Testing every possible input stream is unrealistic because it would take a inordinate amount of time; therefore, many program paths will go untested.
 WhiteBox Testing:
                 Also known as glass box, structural, clear box and open box testing. A software  testing technique whereby explicit knowledge of the internal workings of the item being tested are used to select the test data. Unlike blackbox testing , white box testing uses specific knowledge of programming code to examine outputs. The test is accurate only if the tester knows what the program is supposed to do. He or she can then see if the program diverges from its intended goal. White box testing does not account for errors caused by omission, and all visible code must also be readable. For a complete software examination, both white box and black box tests are required.

Google Chrome Operating System – GooOS

July 9, 2009

“Google Chrome OS is an open source, lightweight operating system that will initially be targeted at netbooks. Later this year google is going to introduce  netbooks running Google Chrome OS will be available for consumers in the second half of 2010. (…) Google Chrome OS will run on both x86 as well as ARM chips and  works with multiple OEMs to bring a number of netbooks to market next year. The software architecture is simple — Google Chrome running within a new windowing system on top of a Linux kernel.”

This idea is not new and there are already operating systems optimized for the browser. For example, Good OS announced last year “Cloud” , an operating system that “integrates a web browser with a compressed Linux operating system kernel for immediate access to Internet, integration of browser and rich client applications, and full control of the computer from inside the browser”. If Google manages to create a great user interface, the new operating system could be very successful.

some of the great posts about the GooOS:

        ” Google is a company that has built a single very large, custom computer. It’s running their   own cluster operating system. They make their big computer even bigger and faster each month, while lowering the cost of CPU cycles. It’s looking more like a general purpose platform than a cluster optimized for a single application.

While competitors are targeting the individual applications Google has deployed, Google is building a massive, general purpose computing platform for web-scale programming.

This computer is running the world’s top search engine, a social networking service, a shopping price comparison engine, a new email service, and a local search/yellow pages engine. What will they do next with the world’s biggest computer and most advanced operating system?”

I was thrilled reading this today because I had been thinking along the same lines as such I wondered about Google Mail (and the 1GB of storage in particular)…and Now Google is not a search engine company.

We have to wait and see how quick people can grasp the opportunity of new Operating system by Google once its bang the global market.

Introduction to Cursors

April 16, 2009

What is a Cursor.

When a query is executed in oracle, a result set is produced and stored in the memory. Oracle allows the programmer to access this result set in the memory through cursors.

Why use a cursor?

Many times, when a query returns more than one row as a result, we might want to go through each row and process the data in different way for them. Cursor is handy here.

Types of cursors:

Oracle PL/SQL declares a cursor implicitly for all queries and DML statements (including queries that return only one row). But in most of the cases we don’t use these cursors for queries that return one row. Based on this, there are 2 types of cursors

1. Explicit cursor
2. Implicit cursor

Explicit cursor:

The programmer declares a cursor explicitly to process the result set of query (Mostly the query that returns multiple rows as result). The following are the steps to use an explicit cursor.

a. Declare the cursor — This means give the cursor a name and associate the query that is going to return multiple rows.
b. Open the cursor — execute the query
c. Fetch the cursor — Get the result set and loop through to process them
d. Close the cursor — Close cursor processing.

Implicit Cursor:

Oracle implicitly opens a cursor to process each sql statement that is not associated with an explicit cursor. An implicit cursor is opened for all queries (even if it returns only one row as the result set).The most recent implicit cursor (that is, the cursor for the most recent query ) can be referred to with SQL cursor. Unlike explicit cursors, there is no necessity to use the OPEN, FETCH and CLOSE statements with these cursors. Instead cursor attributes could be used.

Cursor attributes:

Cursor attributes are variables that take some value about the status of the cursor. These values are automatically set by Oracle and the programmer can read them not write values for them. There are four cursor attributes. They are


1. %FOUND:

After a cursor is opened before the first fetch, the value of this variable is null. After the first fetch, if the query returns one or more rows as result set, this variable is set to TRUE. When a fetch is made after the last row of the result set is reached, this variable is set to FALSE.

This variable is extensively used to in stored procedures to handle exceptions when a query returns no data set. If this variable is referenced before the cursor is opened, an exception INVALID_CURSOR is raised.


This variable is set to TRUE if a cursor is opened and false when the cursor is closed.


This variable is a logical opposite of %FOUND. This variable is set to TRUE if the last fetch returns no rows an FALSE when the last fetch returns a row. This can also be used in exception handing when a query returns no rows.


This variable acts like a counter. It is set to zero when a cursor is opened. Thereafter, with each fetch, the value of this variable is incremented by 1 if the fetch returns a row. This variable is handy when processing needs to be done for only a few rows of the result set.

Methodology for writing small Classes and Methods

March 30, 2009

If you are developer who need to improve their ability to write OO routines, I suggest you have a look-see at this steps. I will try to summarize Jeff Bay’s approach here.

He suggests writing a 1000-line program with the constraints listed below. These constraints are intended to be excessively restrictive, so as to force developers out of the procedural groove. I guarantee if you apply this technique, their code will move markedly towards object orientation. The restrictions are:

1. Use only one level of indentation per method. If you need more than one level, you need to create a second method and call it from the first. This is one of the most important constraints in the exercise.

2. Don’t use the ‘else’ keyword. Test for a condition with an if-statement and exit the routine if it’s not met. This prevents if-else chaining; and every routine does just one thing. You’re getting the idea.

3. Wrap all primitives and strings. This directly addresses “primitive obsession.” If you want to use an integer, you first have to create a class (even an inner class) to identify it’s true role. So zip codes are an object not an integer, for example. This makes for far clearer and more testable code.

4. Use only one dot per line. This step prevents you from reaching deeply into other objects to get at fields or methods, and thereby conceptually breaking encapsulation.

5. Don’t abbreviate names. This constraint avoids the procedural verbosity that is created by certain forms of redundancy—if you have to type the full name of a method or variable, you’re likely to spend more time thinking about its name. And you’ll avoid having objects called Order with methods entitled shipOrder(). Instead, your code will have more calls such as Order.ship().

6. Keep entities small. This means no more than 50 lines per class and no more than 10 classes per package. The 50 lines per class constraint is crucial. Not only does it force concision and keep classes focused, but it means most classes can fit on a single screen in any editor/IDE.

7. Don’t use any classes with more than two instance variables. This is perhaps the hardest constraint. Bay’s point is that with more than two instance variables, there is almost certainly a reason to subgroup some variables into a separate class.

8. Use first-class collections. In other words, any class that contains a collection should contain no other member variables. The idea is an extension of primitive obsession. If you need a class that’s a subsumes the collection, then write it that way.

9. Don’t use setters, getters, or properties. This is a radical approach to enforcing encapsulation. It also requires implementation of dependency injection approaches and adherence to the maxim “tell, don’t ask.”

Taken together, these rules impose a restrictive encapsulation on developers and force thinking along OO lines. I assert than anyone writing a 1000-line project without violating these rules will rapidly become much better at OO.

Weekend fever…

March 26, 2009

Since the sunset too late at 8pm, i dont know what to do in the whole bunch of time in home. So decided to start scraping my daily activites in this blog.

Well, last weekend, i started playing cricket after long long ….long years, its was good experience with my physique… no idea why i was suffering with body pains for 4 days, due to playing cricket like a cricketer…? Even though i feel little bit proud to be allrounder.

Visted to the Dallas Arboretum, which is awesome for the beautiful tulip flowers where i can see different variety of the tulip flowers. Its good place and worth of $10 for the visting the Arboretum. Mostly, we can see these kind of shows in spring season. And we can find Arboretum or blooms in different cities in the USA. Even in india also we can see different variety of the beautifull flowers in Lalbagh Gardens,Bangalore. I remember, i been once for the flower show in lalbagh. In bangalore, they were decorated well around the glass house and here i didt find any sort of decoration, rather than i can see as natual flower shows in the whole garden.

Later on, watched some movies as Billu Barber, Rab Ne Bana Di Jodi, Kocham istam kocham kastam.

Again waiting for the weekend.

Multithreading in C#

March 26, 2009

Any Windows application must have one or more processes. A Process is structural unit with a memory block and using some set of resources. For each executable, the Windows operating system creates some isolated memory block. This C# .Net Tutorial tries to explain the basics of Multithreading in C# .Net.

Every process must have at least one thread. The first thread is created with a process and is known as primary thread. This Primary Thread is entry point of application. In traditional Windows applications it is the method WinMain() and in console applications it is named main().

Main goal of creating multithreading application is performance improvement. As an example, imagine a situation where in a user starts a long process (e.g. copying), he can?t use a single threaded application and wait for an infinite time for the operation to get completed. But if he uses multi?threading application he can set copying process in the background and interact with application without any problems.

At first, if one wants to create a multi-threaded application an important point to be remembered is, a global variable, which is being accessed by different threads, can try to modify the same variable. This is a generic problem, which is solved using a mechanism called Synchronization of threads. Synchronization is nothing but the process of creating some set of rules to operate data or resources.

The C# .Net language has a powerful namespace which can be used for programming with Threads as well as Thread Synchronization in C# .Net programming. The name of the namespace is Sytem.Threading. The most important class inside this namespace for manipulating the threads is the C# .Net class Thread. It can run other thread in our application process.

Sample program on C# Multithreading – C# Tutorial:
The example it creates an additional C# .Net class Launcher. It has only one method, which output countdown in the console.


//Sample for C# tutorial on Multithreading using lock

public void Coundown()


for(int i=4;i>=0;i–)

Console.WriteLine(“{0} seconds to start”,i);






There is a new keyword lock inside the above chunk of .Net C# tutorial code. This provides a mechanism for synchronizing the thread operation. It means at the same point of time only one thread can access to this method of created object. Unless the lock is released after completion of the code, the next routine or iteration cannot enter the block.

To understand it more clearly please have a look at the piece of main method?s code:


Launcher la = new Launcher();

Thread firstThread = new Thread(new ThreadStart(la.Coundown));
Thread secondThread =new Thread(new ThreadStart(la.Coundown));
Thread thirdThread = new Thread(new ThreadStart(la.Coundown));



As you see there were created three additional threads. These threads start a method of object that has Launcher type. The above program is a very simple example of using multi-threading in C#. Net. But C# .Net allows us to create more powerful applications with any level of complexity.

encrypt/decrypt password string

February 25, 2009
Option Explicit

Public Function Encrypt(ByVal icText As String) As String
 Dim icLen As Integer
 Dim icNewText As String
 icChar = ""
    icLen = Len(icText)
    For i = 1 To icLen
        icChar = Mid(icText, i, 1)
        Select Case Asc(icChar)
            Case 65 To 90
                icChar = Chr(Asc(icChar) + 127)
            Case 97 To 122
                icChar = Chr(Asc(icChar) + 121)
            Case 48 To 57
                icChar = Chr(Asc(icChar) + 196)
            Case 32
                icChar = Chr(32)
        End Select
        icNewText = icNewText + icChar
    Encrypt = icNewText
End Function

Public Function Decrypt(ByVal icText As String) As String
 Dim icLen As Integer
 Dim icNewText As String
 icChar = ""
    icLen = Len(icText)
    For i = 1 To icLen
        icChar = Mid(icText, i, 1)
        Select Case Asc(icChar)
            Case 192 To 217
                icChar = Chr(Asc(icChar) - 127)
            Case 218 To 243
                icChar = Chr(Asc(icChar) - 121)
            Case 244 To 253
                icChar = Chr(Asc(icChar) - 196)
            Case 32
                icChar = Chr(32)
        End Select
        icNewText = icNewText + icChar
    Decrypt = icNewText
End Function

Future Nanotechnology Mobiles

February 7, 2009

Continue reading