Tuesday, December 23, 2008

Know Your VALUE..!!!!

A well-known speaker started off his seminar by holding up a Rupee 500 note.

In the room of 200, he asked, "Who would like this Rupee 500 note?"

Hands started going up. He said, "I am going to give this note to one of you but first let me do this." He proceeded to crumple the note up. He then asked, "Who still wants it?"

Still the hands were up in the air.

"Well," he replied, "What if I do this?" And he dropped it on the ground and started to grind it into the floor with his shoe. He picked it up, now all crumpled and dirty. "Now who still wants it?" Still the hands went into the air.

"My friends, you have all learned a very valuable lesson. No matter what I did to the money, you still wanted it because it did not decrease in value. It was still worth Rupee 500/-.

Many times in our lives, we are dropped, crumpled, and ground into the dirt by the decisions we make and the circumstances that come our way. You may feel as though you are worthless! But no matter what has happened or what will happen, you will never lose your value.

You are special. Don't ever forget it! Never let yesterday's disappointments overshadow tomorrow's dreams.

"VALUE HAS A VALUE ONLY IF ITS VALUE IS VALUED"

Posted as-is. This was forwarded by one of my colleague Michael Anand, he doesn’t know the original author of this story. If you are the original author, please let me know. I shall give appropriate credit.

--
Sheo Narayan

Tuesday, December 09, 2008

Exercise for neck pain

At times after few years of working on computer, you may feel severe neck pain. You can feel severe pain in moving your head up or down or left and right.

I had this problem long back after my 3-4 years of software professional career. I started neck exercise and after few days of starting this, I feel great result.

If you or anyone nearby you has the same problem, you can do this exercise.

Process of doing neck exercise:
  1. Sit straight
  2. Touch your chin to the chest
  3. Move towards left slowly inhaling the breath
  4. When your head is at the back (180 degree), hold for a while
  5. Move towards right slowly and come to the initial position (step 2).
  6. Repeat the same 2 more times
  7. Repeat the same other way round (right to left) 3 times.
Do this initially 1-2 times a day after than 2-3 times a day and within few weeks your paint will vanish.

This exercise is so easy that you can do this in office, home virtually anywhere. It takes not more than 3-4 minutes and its result is amazing.

Here are some more links that may help you

http://www.backandbodycare.com/home/neck/neck.htm
http://emzr.com/health/relief-exercise-for-neck.html

Please feel free to write back your comment related with this post.

Thanks

Wednesday, November 12, 2008

Priceless Quote from NR Narayana Murthy

I came across a precious interview from Narayan Murthy, please have a look at it (http://www.moneycontrol.com/india/news/market-outlook/greed-leading-to-disasters-nr-narayana-murthy/365775)

Complete article is precious, however there are priceless words that touched me are below.

That’s why at Infosys we say at 9:00 am when every one of our people is working the marketcap maybe whatever it is, 15-16 in these tough days, but at 6:15 or 7:00 pm when the last of us has gone or maybe 9:00 pm when the last of us has gone home the marketcap is zero. I think that is the fundamental instrument that every corporation must believe in. That’s the power of the mind; the power of the happy, enthusiastic, energetic, satisfied, aspirational mind. The moment you create that rest is all simple.    

Secondly, we hired pretty smart sales people in the industry and that’s why you will notice that we have anywhere from 500-600 basis point of higher operating margin than any of our competitors because we tell them that if the customer thinks that USD 100 is the price – your smartness is to sell it for USD 105 and give the customer USD 110 worth of value. Don’t cheat him, but sell it at USD 105 and provide value of USD 110. That is what we have focused on a lot.

Thirdly, there is tremendous cost consciousness in the company. We are not judged by how opulent our rooms are – we are not judged by whether we travel in this class or that class. So right from the beginning we focused on that. When you focus on middleclass values, when you focus on analytics – it is easy to have a lot of cash in the bank.

 

When a leader has this kind of thought from the beginning who can stop his company to progress? I salute you respected Narayan Murthy.

 

--

Regards,

Sheo Narayan

 

 

Sunday, October 19, 2008

My new blog address

My new blog address is on the cool domain - myfunda.net. http://sheonarayan.myfunda.net I noticed that moving blog address from blogspot.com domain to any custom domain makes a lot of difference for users as well as search engines.

It's all about dream - Part 1

I remember our ex-president Abdul Kalam always used to tell about dream and what role this can play in one's life. I am a dreamy person from the beginning of my life. When I was young in Xth class, I used to dream about my career as an engineer, because of some financial reason at that time, I could n't do this. Then started dreaming about Chartered accountant career but after one year I again failed to achieve that because of lack of support. Then started dreaming about a nice govt. job but again due to some obstacles in my family couldn't get that; again started thinking about a business but because of lack of financial support I failed there also.

How did I come into software sector?

When I was in my native place, heard about LCC (a computer institute) and asked my mom if I can get admission, she fully me supported and fortunately I got admission. At that time I was a full time tutor. I used to teach about 60-70 students of 10th and 12th class a day and used to earn enough money to run myself. Later on I was the best student in that institute and got winner of the year 1998 award and ultimately got selected in campus as "Senior Faculty cum Center Manager". Because of family responsibility I was not moving from my home twon Aurangabad, Bihar but once that got over, I moved to Ranchi, Jharkhand and was earning almost half of money I used to earn in my native place but because I had decided to move so just did. Ranchi, a place of struggle for me - financially, perosally, family everywhere. One day when I was in Ranchi, my landlord's sun came from his school and told me Bhaiya, I will show you something great in your computer, I asked what?

He just opened Ms-Word, wrote a line and selected Marque saved as html and opened in the browser. I was amazed to see that the text he had written was moving horizontally. I was so impressed with that because I remember when I was learning computer, I used to show my tutor Ajay sir a lot of animation using C++ and he use to get impress with my programming skills. But to do that I used to do a lot of home work and a lot of code then used to go to institute and program but here, he just wrote the sentence selected marquee and done :), its cool !!! without any effort. I started dreaming about this and whenever I used to get sometime I used play with this, I used dream in night how and what type of style i can create with this, I used to wakeup in the night started designing pages in Ms Word (Even I didn't know that there is a Front Page software I could have used to develop these things).

Slowly, I started taking interest in learning designing pages but I used to do with Ms Word as I didn't know HTML, one day I found that I can see the actual source of the page too (LOL, I was totally new to IE and Internet world) and slowly started seeing which is doing what and started doing R&D. At that time Internet was very costly and very few people had access to it. I was working in computer but not that was not like web development work. One day I saw a opening in paper for a web site administrator for www.ranchi.com. Just without thinking anything I submitted my resume and was sure I am not going to select. A lot of people had submitted and appeared for the interview but I don't know what he (respected D.Nath sir) saw in me, he rejected all of them and selected me. I was interviewed by his sons (from USA) and finally got a job where there was Internet and real job in developing web pages. The salary was almost 3 times more than what I used to get in my last job :)

I started learning html the slowly asp. Ranchi was a small place so hardly people knew about these things. I struggled a lot in learning these things, used to spend a lot of time just drawing a html table in the way I wanted to draw; connecting to Ms Access database.

Continue in next post - whenever get time :)

Monday, September 08, 2008

List of article got published on www.asp.net & www.windowsclient.net


List of articles got published on www.asp.net (Microsoft's official website for ASP.NET) as "Article of the Day" in last 3 weeks
Sunday, September 07, 2008 by Sheo Narayan
In the process of developing an application, there are situations when you need to pass a particular value from user control to its calling page. This article describes solution to that type of problem in an easy to follow steps.\
Monday, September 01, 2008 by Sheo Narayan
This article shows how to paginate (SEO friendly) a ListView using the DataPager control without enabling ViewState.
Sunday, August 24, 2008 by Sheo Narayan
In this article, I am going to show how to serialize and deserialize an object (can be a collection object) into XML format using the ASP.NET System.Xml.Serialization.XmlSerializer class.
Saturday, August 23, 2008 by Sheo Narayan
In this article, I am going to describe what are the main differences between asp:LinkButton, asp:ImageButton, asp:Button and asp:HyperLink control and how/where to use them effectively.
List of articles got published on www.asp.net (Microsoft's official website for WPF and Window Forms) as "Article of the Day" this week

DataTable: Adding, Modifying, Deleting, Filtering, Sorting
Monday, September 08, 2008 by Sheo Narayan
Sheo Narayan explains how to add, modify, delete, sort, and filter DataTable rows, how to load data from and write data to XML files, and how to read and write DataTable XML schemas...

Update on 19-Oct-08: Some more articles got published, couldn't track them.

--
Thanks
Sheo Narayan

Wednesday, August 13, 2008

How fortunate I am

Below is the part of an email sent by one of my collegue. This shows how fortunate I am that I have people like him around me.

-------------------------------
Hi, Sheo Brother

"Dua hai Ki Kamyabi ke har sikhar pe aap ka naam hoga,
aapke har kadam par duniya ka salam hoga,
Himat se mushkilon ka samana karna
hamari dua hai ki waqt bhi ek din aapka gulam hoga"

--
Anant
-------------------------------

Wednesday, August 06, 2008

Receiving a lot of emails from DotNetFunda.com visitors

Dear DotNetFunda.com Visitors,

Daily, I am receiving a lot of emails from visitors of www.dotnetfunda.com coveying their thanks, appreciation for the article I have written and sometimes asking some questions.


I acknowledge all thanks and appreciation from everybody who sent me a personal email (Sorry from those whom I couldn't manage to reply personally).


I sincerely request to all visitors to not send an email to my personal email id and Respond to the article to convey your thanks, appreciation or comments.

To ask a question, please use Questions section of www.dotnetfunda.com


--
Thanks and regards,
Sheo Narayan

Friday, July 18, 2008

A Leader Should Know How to Manage Failure

'A Leader Should Know How to Manage Failure'


(Former President of IndiaAPJ Abdul Kalam at Wharton IndiaEconomic forum ,Philadelphia , March 22,2008)

Question: Could you give an example, from your own experience, of how leaders should manage failure?

Kalam: Let me tell you about my experience. In 1973 I became the project director of India 's satellite launch vehicle program, commonly called the SLV-3. Our goal was to put India's "Rohini" satellite into orbit by 1980. I was given funds and human resources -- but was told clearly that by 1980 we had to launch the satellite into space. Thousands of people worked together in scientific and technical teams towards that goal.

By 1979 -- I think the month was August -- we thought we were ready. As the project director, I went to the control center for the launch. At four minutes before the satellite launch, the computer began to go through the checklist of items that needed to be checked. One minute later, the computer program put the launch on hold; the display showed that some control components were not in order. My experts -- I had four or five of them with me -- told me not to worry; they had done their calculations and there was

enough reserve fuel. So I bypassed the computer, switched to manual mode, and launched the rocket. In the first stage, everything worked fine. In the second stage, a problem developed. Instead of the satellite going into orbit, the whole rocket system plunged into the Bay of Bengal . It was a big failure.

That day, the chairman of the Indian Space Research Organization, Prof. Satish D hawan, had called a press conference. The launch was at 7:00 am, and the press conference -- where journalists from around the world were present -- was at 7:45 am at ISRO's satellite launch range in Sriharikota [in Andhra Pradesh in southern India ]. Prof. Dhawan, the leader of the organization, conducted the press conference himself. He took responsibility for the failure -- he said that the team had worked very hard, but that it needed more technological support. He assured the media that in another

year, the team would definitely succeed. Now, I was the project director, and it was my failure, but instead, he took responsibility for the failure as chairman of the organization.

The next year, in July 1980, we tried again to launch the satellite – and this time we succeeded. The whole nation was jubilant. Again, there was a press conference. Prof. Dhawan called me aside and told me, "You conduct the press conference today."

I learned a very important lesson that day. When failure occurred, the leader of the organization owned that failure. When success came, he gave it to his team. The best management lesson I have learned did not come to me from reading a book; it came from that experience.

Never limit your challenges; challenge your limits....

Monday, June 02, 2008

Government of India online Grievance forum

Dear All,Government of India has an online Grievance forum at http://pgportal.gov.in/
Can you imagine this is happening in INDIA?

The govt. wants people to use this tool to highlight the problems they faced while dealing with Government officials or departments like Passport Office, Electricity board, BSNL/MTNL, Railways etc.

I know many people will say that these things don't work in India, but this actually works as one of our colleague in CSC found. The guy I'm talking about lives in Faridabad. Couple of months back, the Faridabad Municipal Corporation laid new roads in his area and the residents were very happy about it. But 2 weeks later, BSNL dug up the newly laid roads to install new cables which annoyed all the residents including this guy. But it was only this guy! Who used the above listed grievance forum to highlight his concern. And to his surprise, BSNL and Municipal Corporation of Faridabad were served a show cause notice and the guy received a copy of the notice in one week. Government has asked the MC and BSNL about the goof up as it's clear that both the government departments were not in sync at all.

So use this grievance forum and educate others who don't know about this facility. This way we can at least raise our concerns instead of just talking about the ' System ' in India. Invite your friends to contribute for many such happenings.

PLEASE SPREAD THIS MESSAGE IF U WANT OUR INDIA TO HAVE A BETTER TOMORROW & FORWARD THIS MAIL TO AS MANY AS POSSIBLE.

New Google Favicon

Many people noticed a small change: Google has a new favicon. A favicon is a small image that is generally used to reflect the identity of a web site. You can find it in the address bar, in your browser's tabs, in the list of bookmarks or in some feed readers like Bloglines.

Google's favicon is hosted at
google.com/favicon.ico and it's a 16x16 pixels image, a standard size for favicons. Google replaced the upper-case "G" in blue border, green and red borders with a lower-case purple "g" in a rounded corner rectangle.
Before


After


The first time when I saw the new favicon at Google Image Search, I thought there was something wrong with my browser's cache or I typed an incorrect address. Google's new favicon is less cheerful and comforting, but it makes a lot of sense: the small g is a symbol for infinity (∞). A googol (10100) is just a poor approximation for the huge amount of information that needs to be indexed, organized and made useful by Google.


Source: http://googlesystem.blogspot.com/2008/05/new-google-favicon.html

Thursday, May 22, 2008

.NET Interview Questions (Microsoft technology interview questions)

Basic .NET Framework questions

What is IL? (Twist :- What is MSIL or CIL , What is JIT?)
What is the CLR?
What is the CTS?
What is CLS(Common Language Specification)?
What is Managed Code?
What is Assembly ?
What are different types of Assembly?
What is NameSpace?
What is Difference between NameSpace and Assembly?
If you want to view a Assembly how to you go about it (Twist : What is ILDASM ?) ?
What is Manifest?
Where is version information stored of a assembly ?
Is versioning applicable to private assemblies?
What is GAC (Twist :- What are situations when you register .NET assembly in GAC ?) ?
What is concept of strong names (Twist :- How do we generate strong names or what is the process of generating string names , What is use of SN.EXE , How do we apply strong names to assembly ? , How do you sign an assembly ?)?
How to add and remove a assembly from GAC?
What is Delay signing ?
What is garbage collection?
Can we force garbage collector to run ?
What is reflection?
What are different type of JIT ?
What are Value types and Reference types ?
What is concept of Boxing and Unboxing ?
What’s difference between VB.NET and C# ?
What’s difference between System exceptions and Application exceptions?
What is CODE Access security?

NET Interoperability
 

How can we use COM Components in .NET (Twist : What is RCW ?)?
Once i have developed the COM wrapper do i have to still register the COM in registry?
How can we use .NET components in COM (Twist :- What is CCW (COM callable wrapper) ?, What caution needs to be taken in order that .NET components is compatible
with COM ?) ?
How can we make Windows API calls in .NET?
When we use windows API in .NET is it managed or unmanaged code ?
What is COM ?
What is Reference counting in COM ?
Can you describe IUKNOWN interface in short ?
Can you explain what is DCOM ?
How do we create DCOM object in VB6?
How to implement DTC in .NET ?
How many types of Transactions are there in COM + .NET ?
How do you do object pooling in .NET ?
What are types of compatibility in VB6?

Threading

What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Did VB6 support multi-threading ?
Can we have multiple threads in one App domain ?
Which namespace has threading ?
Can you explain in brief how can we implement threading ?
How can we change priority and what the levels of priority are provided by .NET ?
What does Addressof operator do in background ?
How can you reference current thread of the method ?
What's Thread.Sleep() in threading ?
How can we make a thread sleep for infinite period ?
What is Suspend and Resume in Threading ?
What the way to stop a long running thread ?
How do i debug thread ?
What's Thread.Join() in threading ?
What are Daemon thread's and how can a thread be created as Daemon?
When working with shared data in threading how do you implement synchronization ?
Can we use events with threading ?
How can we know a state of a thread?
what is a monitor object?
what are wait handles ?(Twist :- What is a mutex object ?)
what is ManualResetEvent and AutoResetEvent ?
What is ReaderWriter Locks ?
How can you avoid deadlock in threading ?
What’s difference between thread and process?

Remoting and Webservices

What is an application domain?
What is .NET Remoting ?
Which class does the remote object has to inherit ?
What are two different types of remote object creation mode in .NET ?
Describe in detail Basic of SAO architecture of Remoting?
What is the situation you will use singleton architecture in remoting ?
What is fundamental of published or precreated objects in Remoting ?
What are the ways client can create object on server in CAO model ?
Are CAO stateful in nature ?
In CAO model when we want client objects to be created by “NEW” keyword is there any precautions to be taken ?
Is it a good design practice to distribute the implementation to Remoting Client ?
What is LeaseTime,SponsorshipTime ,RenewonCallTime and LeaseManagerPollTime?
Which config file has all the supported channels/protocol ?
How can you specify remoting parameters using Config files ?
Can Non-Default constructors be used with Single Call SAO?(Twist :- What are the limitation of constructors for Single call SAO ?)
How can we call methods in remoting Asynchronously ?
What is Asynchronous One-Way Calls ?
What is marshalling and what are different kinds of marshalling ?
What is ObjRef object in remoting ?
What is a WebService ?
What is UDDI ?
What is DISCO ?
What is WSDL?
What the different phase of acquiring a proxy object in Webservice ?
What is file extension of Webservices ?
Which attribute is used in order that the method can be used as WebService ?
What are the steps to create a webservice and consume it ?
Do webservice have state ?

Caching Concepts

What is application object ?
What’s the difference between Cache object and application object ?
How can get access to cache object ?
What are dependencies in cache and types of dependencies ?
Can you show a simple code showing file dependency in cache ?
What is Cache Callback in Cache ?
What is scavenging ?
What are different types of caching using cache object of ASP.NET?
How can you cache different version of same page using ASP.NET cache object ?
How will implement Page Fragment Caching ?
What are ASP.NET session and compare ASP.NET session with classic ASP session variables?
Which various modes of storing ASP.NET session ?
Is Session_End event supported in all session modes ?
What are the precautions you will take in order that StateServer Mode work properly ?
What are the precautions you will take in order that SQLSERVER Mode work properly ?
Where do you specify session state mode in ASP.NET ?
What are the other ways you can maintain state ?
What are benefits and Limitation of using Hidden fields ?
What is ViewState ?
Do performance vary for viewstate according to User controls ?
What are benefits and Limitation of using Viewstate for state management?
How an you use Hidden frames to cache client data ?
What are benefits and Limitation of using Hidden frames?
What are benefits and Limitation of using Cookies?
What is Query String and What are benefits and Limitation of using Query Strings?

OOPS

What is Object Oriented Programming ?
What’s a Class ?
What’s a Object ?
What’s the relation between Classes and Objects ?
What are different properties provided by Object-oriented systems ?(Twist :- Can you explain different properties of Object Oriented Systems?)(Twist :- What’s difference between Association , Aggregation and Inheritance relationships?)
How can we acheive inheritance in VB.NET ?
What are abstract classes ?
What’s a Interface ?
What is difference between abstract classes and interfaces?
What is a delegate ?
What are event’s ?
Do events have return type ?
Can event’s have access modifiers ?
Can we have shared events ?
What is shadowing ?
What’s difference between Shadowing and Overriding ?
What’s difference between delegate and events?
If we inherit a class do the private variables also get inherited ?
What are different accessibility levels defined in .NET ?
Can you prevent a class from overriding ?
What’s the use of “MustInherit” keyword in VB.NET ?
Why can not you specify accessibility modifier in Interface ?
What are similarities between Class and structure ?
What’s a difference between Class and structure’s ?
What does virtual keyword mean ?
What are shared (VB.NET)/Static(C#) variables?
What is Dispose method in .NET ?
Whats the use of “OverRides” and “Overridable” keywords ?
Where are all .NET Collection classes located ?
What is ArrayList ?
What’s a HashTable ?(Twist :- What’s difference between HashTable and ArrayList ? )
What are queues and stacks ?
What is ENUM ?
What is nested Classes ?
What’s Operator Overloading in .NET?
In below sample code if we create a object of class2 which constructor will fire first ?
What’s the significance of Finalize method in .NET?
Why is it preferred to not use finalize for clean up?
How can we suppress a finalize method?
What’s the use of DISPOSE method?
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method?
In what instances you will declare a constructor to be private?

ASP.NET

 What’s the sequence in which ASP.NET events are processed ?
In which event are the controls fully loaded ?
How can we identify that the Page is PostBack ?
How does ASP.NET maintain state in between subsequent request ?
What is event bubbling ?
How do we assign page specific attributes ?
Administrator wants to make a security check that no one has tampered with ViewState , how can we ensure this ?
What’s the use of @ Register directives ?
What’s the use of SmartNavigation property ?
What is AppSetting Section in “Web.Config” file ?
Where is ViewState information stored?
What’s the use of @ OutputCache directive in ASP.NET?
How can we create custom controls in ASP.NET ?
How many types of validation controls are provided by ASP.NET ?
Can you explain what is “AutoPostBack” feature in ASP.NET ?
How can you enable automatic paging in DataGrid ?
What’s the use of “GLOBAL.ASAX” file ?
What’s the difference between “Web.config” and “Machine.Config” ?
What’s a SESSION and APPLICATION object ?
What’s difference between Server.Transfer and response.Redirect ?
What’s difference between Authentication and authorization?
What is impersonation in ASP.NET ?
Can you explain in brief how the ASP.NET authentication process works?
What are the various ways of authentication techniques in ASP.NET?
How does authorization work in ASP.NET?
What’s difference between Datagrid , Datalist and repeater ?
From performance point of view how do they rate ?
What’s the method to customize columns in DataGrid?
How can we format data inside DataGrid?
How will decide the design consideration to take a Datagrid , datalist or repeater ?
Difference between ASP and ASP.NET?
What are major events in GLOBAL.ASAX file ?
What order they are triggered ?
Do session use cookies ?
How can we force all the validation control to run ?
How can we check if all the validation control are valid and proper ?
If you have client side validation is enabled in your Web page , Does that mean server side code is not run?
Which JavaScript file is referenced for validating the validators at the client side ?
How to disable client side script in validators?
I want to show the entire validation error message in a message box on the client side?
You find that one of your validation is very complicated and does not fit in any of the validators , so what will you do ?
What is Tracing in ASP.NET ?
How do we enable tracing ?
What exactly happens when ASPX page is requested from Browser?
How can we kill a user session ?
How do you upload a file in ASP.NET ?
How do I send email message from ASP.NET ?
What are different IIS isolation levels?

.NET Architecture

What are design patterns ?
What’s difference between Factory and Abstract Factory Pattern’s?
What’s MVC pattern? (Twist: - How can you implement MVC pattern in ASP.NET? )
How can we implement singleton pattern in .NET?
How do you implement prototype pattern in .NET?(Twist: - How to implement cloning in .NET ? , What is shallow copy and deep copy ?)
What are the situations you will use a Web Service and Remoting in projects?
Can you give a practical implementation of FAƇADE patterns?
How can we implement observer pattern in .NET?
What is three tier architecture?
Have you ever worked with Microsoft Application Blocks, if yes then which?
What is Service Oriented architecture?

ADO.NET

What is the namespace in which .NET has the data functionality classes ?
Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What is the use of command objects and what are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
How do we connect to SQL SERVER , which namespace do we use ?
How do we use stored procedure in ADO.NET and how do we provide parameters to the stored procedures?
How can we force the connection object to close after my datareader is closed ?
I want to force the datareader to return only schema of the datastore rather than data ?
How can we fine tune the command object when we are expecting a single row or a single value ?
Which is the best place to store connectionstring in .NET projects ?
What are steps involved to fill a dataset ?(Twist :- How can we use dataadapter to fill a dataset ?)
What are the various methods provided by the dataset object to generate XML?
How can we save all data from dataset ?
How can we check that some changes have been made to dataset since it was loaded ?(Twist :- How can cancel all changes done in dataset ? ,How do we get changed value dataset ? )
How add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?
Which are namespaces for ADO.NET?
Can you give a overview of ADO.NET architecture ?
What are the two fundamental objects in ADO.NET ?
What is difference between dataset and datareader ?
What are major difference between classic ADO and ADO.NET ?
What is the use of connection object ?
What are the methods provided by the command object ?
What is the use of dataadapter ?
What are basic methods of Dataadapter ?
What is Dataset object?
What are the various objects in Dataset ?
How can we connect to Microsoft Access , Foxpro , Oracle etc ?
What’s the namespace to connect to SQL Server?
How do we use stored procedure in ADO.NET?
How can we force the connection object to close?
I want to force the datareader to return only schema?
Can we optimize command object when there is only one row?
Which is the best place to store connectionstring ?
What are steps involved to fill a dataset ?
What are the methods provided by the dataset for XML?
How can we save all data from dataset ?
How can we check for changes made to dataset?
How can we add/remove row’s in “DataTable” object of “DataSet” ?
What’s basic use of “DataView” ?
What’s difference between “DataSet” and “DataReader” ?
How can we load multiple tables in a DataSet ?
How can we add relation’s between table in a DataSet ?
What’s the use of CommandBuilder ?
What’s difference between “Optimistic” and “Pessimistic” locking ?
How many way’s are there to implement locking in ADO.NET ?
How can we perform transactions in .NET?
What’s difference between Dataset. clone and Dataset. copy ?
Whats the difference between Dataset and ADO Recordset?

.NET Integration


What are steps to load a .NET code in SQL SERVER 2005?
How can we drop a assembly from SQL SERVER?
Are changes made to assembly updated automatically in database?
Why do we need to drop assembly for updating changes?
How to see assemblies loaded in SQL Server?
I want to see which files are linked with which assemblies?
Does .NET CLR and SQL SERVER run in different process?
Does .NET controls SQL SERVER or is it vice-versa?
Is SQLCLR configured by default?
How to configure CLR for SQL SERVER?
Is .NET feature loaded by default in SQL Server?
How does SQL Server control .NET run-time?
What’s a “SAND BOX” in SQL Server 2005?
What is a application domain?
How are .NET Appdomain allocated in SQL SERVER 2005?
What is Syntax for creating a new assembly in SQL Server 2005?
Do Assemblies loaded in database need actual .NET DLL?
Does SQL Server handle unmanaged resources?
What is Multi-tasking ?
What is Multi-threading ?
What is a Thread ?
Can we have multiple threads in one App domain ?
What is Non-preemptive threading?
What is pre-emptive threading?
Can you explain threading model in SQL Server?
How does .NET and SQL Server thread work?
How are exception in SQLCLR code handled?
Are all .NET libraries allowed in SQL Server?
What is “Hostprotectionattribute” in SQL Server 2005?
How many types of permission level are there for an assembly?
Can you name system tables for .NET assemblies?
Are two version of same assembly allowed in SQL Server?
How are changes made in assembly replicated?
Is it a good practice to drop a assembly for changes?
In one of the projects following steps where done, will it work?
What does Alter assembly with unchecked data signify?
How do I drop an assembly?
Can we creat SQLCLR using .NET framework 1.0?
While creating .NET UDF what checks should be done?
How do you define a function from the .NET assembly?
Can compare between T-SQL and SQLCLR ?
With respect to .NET is SQL SERVER case sensitive?
Does case sensitive rule apply for VB.NET?
Can nested classes be accessed in T-SQL?
Can we have SQLCLR procedure input as array?
Can object datatype be used in SQLCLR?
How’s precision handled for decimal datatypes in .NET?
How do we define INPUT and OUTPUT parameters in SQLCLR?
Is it good to use .NET datatypes in SQLCLR?
How to move values from SQL to .NET datatypes?
What is System.Data.SqlServer?
What is SQLContext?
Can you explain essential steps to deploy SQLCLR?
How do create function in SQL Server using .NET?
How do we create trigger using .NET?
How to create User Define Functions using .NET?
How to create User Defined Create aggregates using .NET?
What is Asynchronous support in ADO.NET?
What is MARS support in ADO.NET?
What is SQLbulkcopy object in ADO.NET ?
How to select range of rows using ADO.NET?

SQL SERVER

What is normalization? What are different type of normalization?
What is denormalization ?
What is a candidate key ?
What are different types of joins and whats the difference between them ?
What are indexes and What is the difference between clustered and nonclustered indexes?
How can you increase SQL performance ?
What is the use of OLAP ?
What's a measure in OLAP ?
What are dimensions in OLAP ?
What are levels in dimensions ?
What are fact tables and dimension tables in OLAP ? (Twist :- can you explain the star schema for OLAP ? )
What is DTS?
What is fillfactor ? (Twist :- When does plage split occurs ?)
What is RAID and how does it work ?
What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
What are the problems that can occur if you do not implement locking properly in SQL SERVER ?
What are different transaction levels in SQL SERVER ?(Twist :- what are different types of locks in SQL SERVER ?)
What are different locks in SQL SERVER ?
Can we suggest locking hints to SQL SERVER ?
What is LOCK escalation?
What are the different ways of moving data/databases between servers and databases in SQL Server?
What are advantages of SQL 2000 over SQl 7.0 ?
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
What is difference between UNION and UNION ALL SQL syntax ?
How can you raise custom errors from stored procedure ?
What is ACID fundamental and what are transactions in SQL SERVER ?
What is DBCC?
What is purpose of Replication ?
What are different type of replication supported by SQL SERVER ?
What is BCP utility in SQL SERVER ?
What are different types of triggers in SQl SERVER 2000 ?
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ?
What is SQl injection ?

UML

What is UML?
How many types of diagrams are there in UML ?(Twist :- Explain in short all types of diagrams in UML ?)
What are advantages of using UML?(Twist: - What is Modeling and why UML ?)
What’s the sequence of UML diagrams in project?(Twist: - How did you implement UML in your project?)
Just a small Twist: - Do I need all UML diagrams in a project?
Give a small brief explanation of all Elements in activity diagrams?
Explain Different elements of a collaboration diagram ?
Explain Component diagrams ?
Explain all parts of a deployment diagram?
Describe various components in sequence diagrams?
What are the element in State Chart diagrams ?
Describe different elements in Static Chart diagrams ?
Explain different elements of a Use Case ?(Twist: - What’s difference between Activity and sequence diagrams?(I leave this to the readers))

Project Management

What is project management?
Is spending in IT project’s constant through out the project?
Who is a stakeholder ?
Can you explain project life cycle ?(Twist :- How many phases are there in software project ?)
Are risk constant through out the project ?
Can you explain different software development life cycles ?
What is triple constraint triangle in project management ?
What is a project baselines ?
What is effort variance?
How is normally a project management plan document organized ?
How do you estimate a project?
What is CAR (Causal Analysis and Resolution)?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing ?
What are the software you have used for project management?
What are the metrics followed in project management?(Twist: - What metrics will you look at in order to see the project is moving successfully?)
You have people in your team who do not meet there deadlines or do not perform what are the actions you will take ? (Twist :- Two of your resources have conflict’s between them how would you sort it out ?)
How do you start a project?
How did you do resource allocations?
How do you do code reviews ?

Database Concepts

What is a database or database management systems (DBMS)?
What’s difference between DBMS and RDBMS ?
What are CODD rules?
Is access database a RDBMS?
What’s the main difference between ACCESS and SQL SERVER?
What’s the difference between MSDE and SQL SERVER 2000?
What is SQL SERVER Express 2005 Edition?
What is SQL Server 2000 Workload Governor?
What’s the difference between SQL SERVER 2000 and 2005?
What are E-R diagrams?
How many types of relationship exist in database designing?
Can you explain Fourth Normal Form?
Can you explain Fifth Normal Form?
What’s the difference between Fourth and Fifth normal form?
Have you heard about sixth normal form?
What is Extent and Page?
What are the different sections in Page?
What are page splits?
In which files does actually SQL Server store data?
What is Collation in SQL Server?
Can we have a different collation for database and table?

SQL

Revisiting basic syntax of SQL?
What are “GRANT” and “REVOKE’ statements?
What is Cascade and Restrict in DROP table SQL?
What is a DDL, DML and DCL concept in RDBMS world?
What are different types of joins in SQL?
What is “CROSS JOIN”?
You want to select the first record in a given set of rows?
How do you sort in SQL?
How do you select unique rows using SQL?
Can you name some aggregate function is SQL Server?
What is the default “SORT” order for a SQL?
What is a self-join?
What's the difference between DELETE and TRUNCATE ?
Select addresses which are between ‘1/1/2004’ and ‘1/4/2004’?
What are Wildcard operators in SQL Server?
What’s the difference between “UNION” and “UNION ALL” ?
What are cursors and what are the situations you will use them?
What are the steps to create a cursor?
What are the different Cursor Types?
What are “Global” and “Local” cursors?
What is “Group by” clause?
What is ROLLUP?
What is CUBE?
What is the difference between “HAVING” and “WHERE” clause?
What is “COMPUTE” clause in SQL?
What is “WITH TIES” clause in SQL?
What does “SET ROWCOUNT” syntax achieves?
What is a Sub-Query?
What is “Correlated Subqueries”?
What is “ALL” and “ANY” operator?
What is a “CASE” statement in SQL?
What does COLLATE Keyword in SQL signify?

Notification Services


What are notification services?
What are basic components of Notification services?
Can you explain architecture of Notification Services?
Which are the two XML files needed for notification services?
What is Nscontrols command?
What are the situations you will use “Notification” Services?

Service Broker


What do we need Queues?
What is “Asynchronous” communication?
What is SQL Server Service broker?
What are the essential components of SQL Server Service broker?
What is the main purpose of having Conversation Group?
How to implement Service Broker?
How do we encrypt data between Dialogs?
 

XML Integration


What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What’s the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is Element and attributes in XML?
Can we define a column as XML?
How do we specify the XML data type as typed or untyped?
How can we create the XSD schema?
How do I insert in to a table which has XSD schema attached to it?
What is maximum size for XML datatype?
What is Xquery?
What are XML indexes?
What are secondary XML indexes?
What is FOR XML in SQL Server?
Can I use FOR XML to generate SCHEMA of a table and how?
What is the OPENXML statement in SQL Server?
I have huge XML file which we want to load in database?
How to call stored procedure using HTTP SOAP?
What is XMLA ?

Database Optimization


What are indexes?
What are B-Trees?
I have a table which has lot of inserts, is it a good database design to create indexes on that table?
What are “Table Scan’s” and “Index Scan’s”?
What are the two types of indexes and explain them in detail?
What is “FillFactor” concept in indexes?
What is the best value for “FillFactor”?
What are “Index statistics”?
How can we see statistics of an index?
How do you reorganize your index, once you find the problem?
What is Fragmentation?
How can we measure Fragmentation?
How can we remove the Fragmented spaces?
What are the criteria you will look in to while selecting an index?
What is “Index Tuning Wizard”?
What is an Execution plan?
How do you see the SQL plan in textual format?
What is nested join, hash join and merge join in SQL Query plan?
What joins are good in what situations? 298

Transaction and Locks 


What is a “Database Transactions “?
What is ACID?
What is “Begin Trans”, “Commit Tran”, “Rollback Tran” and “Save Tran”?
What are “Checkpoint’s” in SQL Server?
What are “Implicit Transactions”?
Is it good to use “Implicit Transactions”?
What is Concurrency?
What kind of problems occurs if we do not implement proper locking strategy?
What are “Dirty reads”?
What are “Unrepeatable reads”?
What are “Phantom rows”?
What are “Lost Updates”?
What are different levels of granularity of locking resources?
What are different types of Locks in SQL Server?
What are different Isolation levels in SQL Server?
If you are using COM+ what “Isolation” level is set by default?
What are “Lock” hints?
What is a “Deadlock” ?
What are the steps you can take to avoid “Deadlocks” ?
How can I know what locks are running on which resource?

 

Credit goes to SREENIVAS.S

Sunday, May 18, 2008

Is overloading method by return type permitted in C#?

No, overloading methods by return type is not permitted in C#

void Method();
void Method(int a); //ok: different parameter set
void Method(string a, int b);//ok again
void Method(string h, int t);//error same parameter set as previous method
int Method(int g); //error: can't overload based on return type only

Sunday, May 11, 2008

Writing SEO friendly url using HttpHandlers in ASP.NET

In general it is recommend to not use querystring in the url as search engines doesn't rank those pages well and give very low priority. To avoid querystring there are several third party component that can be used like ISAPI, url rewriter. However in this article, I am going to show you how to rewrite url using ASP.NET built in HttpHandler.
 
Introduction

HttpHandler is the low level Request and Response API to service incoming Http requests. All handlers implement the IHttpHandler interface. There is no need to use any extra namespace to use it as it contains in the System.Web namespace. Handlers are somewhat analogous to Internet Server Application Programming Interface (ISAPI) extensions.

In this article, I am going to explain how to use HttpHandler to create a SEO friendly as well as user friendly url. During this article I will create two .aspx file, one HandlerUrl.cs class file. I am assuming here that I have to show different article based on the id I get from the request. But I will not get the id as querystring but as part of the name of the page like article1.aspx or article2.aspx. Here 1 and 2 is my article id. I will extract it and send into my page (showarticle.aspx) using Server.Transfer method so that my url in the browser will be like article1.aspx but internally it will be served as showarticle.aspx?id=1.
 

How to use Connection object efficiently

In this article, I am going to show how to use Connection object efficiently and what are the standard practices we should follow while working with connection objects.
 
 Irrespective of what .NET data provider we are using we should consider following points.

1. Open the database connection as late as possible, Just open it before you are going to use it.
2. Use the connection object for as short period as possible. Don't let it open even if you are not using.
3. Close the connection as soon as possible. You can do that by calling Close() or Dispose() method of the connection object. This also ensures that you connection is closed even if it is into broken stage.

To guarantee that the connection has been closed before method returns, consider using finally block or use using statement in C#.

Using Finally block to ensure that connection has been closed


SqlConnection conn = new SqlConnection(connStr1);
try
{
conn.Open();
// Do your work
}
catch (Exception ee)
{
lblMessage.Text = ee.Message;
}
finally
{
conn.Close();
conn.Dispose();

}


using statement to ensures that connection has been closed

private void UsingStatement()
{
// using guarantees that Dispose() method of the object has been called before
// In this case as soon as you will finish doing your work using will automatically call conn.Dispose() and closes the connection
using (SqlConnection conn = new SqlConnection(connStr))
{
// do your work
}


// Connection object is not available here
}

You can apply using statement to all methods that implement IDisposable interface (Objects that has Dispose() method) like SqlDataReader, SqlDataAdapter etc.

Conclusion

The conclusion here is that database Connection is very precious resources for any application and you should use it very efficiently to make your application scalable and error free.

When to use of DataSet, SqlDataReader and XmlReader

To efficiently write the code of Data Access Layer we must be aware about the functionality/features of DataSet, SqlDataReader and XmlReader. In this article, I am trying to describe which objects fits in what scenario.
 
 Introduction

When we need to retrive mutliple records from databsae, we have following options
1. DataSet or DataTable. use SqlDataAdapter to generate it
2. SqlDataReader. Use it to provide read only, forward only data stream
3. XmlReader. Use it to provide a read only, forward only data stream of XML data.

The choice between SqlDataReader and DataSet/DataTable is essentially one of the performance vs functionality issue. We should use SqlDataReader to gain optimum performance while DataSet/DataTable gain additional functionality and flexibility.

Use DataSet

We should use a DataSet populated by SqlDataAdapter when

1. We require a disconnected memory-resident cache of data so that we can pass to different component or layers
2. We are working wtih data retrived from multiple data sources.
3. We want to update some of all retrieved rows using batch updated provided by SqlDataAdapter
4. We want to perform data binding against a control that requires a data source that spport IList such as GridView, Repeater etc.

Whenever we are using SqlDataAdapter to generate DataSet or DataTable, following points should be considered.

1. We don't need to explicitly open or close the database connection as SqlAdapter Fill method opens the database connection and then closes it before it returns. If the connection is already open (before using it into SqlDataAdapter) then it leaves it as it is.
2. If we require the connection object to use it further then better to open the connection before calling Fill method of SqlDataAdapter to avoid reopening it again.

Use SqlDataReader


We should use SqlDataReader by calling ExecuteReader method of SqlCommand object when

1. We are dealing with large volumes of data - too much to maintain in single cache.
2. We want to reduce the memory occupied by the application (using DataSet consumes memory)
3. We want to perform data binding with a control that supports a data source that implements IEnumerable.

When we are using SqlDataReader, following points should be considered.

1. The underlying connection to the databse remains open and cannot be used for any other purpose while the data reader is active. So we should all conn.Close() method as soon as possible.
2. There can be only one reader per connection.
3. Better to use CommandBehavior.CloseConnection (dCmd.ExecuteReader(CommandBehavior.CloseConnection)) to close the connection. This indicates that the connection should be closed when the SqlDataReader is closed.
4. When accessing data by using the reader, use the typed accessor methods like GetInt32, GetString as they reduce the amound ot type convertion required when reading the column data.
5. To avoid unnecessary data pulling from the datbase, use Cancel method of Command object (dCmd.Cancel()) before closing the reader. (lets say you have 100 records into the reader and after looping through 10 records you think that you got the data you needed then before closing the reader call Cancel method of the command object) This ensures that the results are discarded on the server and are not pulled unnecessarily to the client.

Use XmlReader

Use an XmlReader obtained by calling the ExecuteXmlReader method of SqlCommand object when
1. We want to process the retrieve as XML but we don't want to incur the overhead of creating DataSet.

When we are using XmlReader following points should be considered
1. The connection must remain open while we read the data from XmlReader. There is no support of CommandBehavior.CloseConnection as in case of SqlDataReader so we should close the connection explicitly.


Conclusion

We generally do these activities on almost all projects, a little attention on what to use when increases the performance of the overall project and increases the scalability.
 

Thursday, May 08, 2008

How to get value from TextBox, RadioButtonList, DropDownList, CheckBox through JavaScript

In this article I am going to show how to get value from asp.net controls like TextBox, RadioButtonList, DropDownList, CheckBoxes.

 

Introduction

In day to day life generally we need to get values from asp.net server controls through JavaScript while developing web applications. I found several questions on the internet for the same subject. In this article I am going to show how to get values from asp.net controls like TextBox, RadioButtonList, DropDownList, CheckBoxes.


For original article, visit http://www.dotnetfunda.com/articles/article72.aspx

Loading Multiple Versions of same Assembly

Very Good and Unique Stuff – Copied from http://www.infosysblogs.com/microsoft/2007/04/loading_multiple_versions_of_s.html Thanks to Atul for sharing withh us.
The author of this article is: Atul Gupta

 

The other day a colleague asked if there was a way he could work with different versions of the same assembly in his code i.e. could he invoke say Method A on Version 1.0 and Method B on Version 2.0 of the same assembly?

I was initially surprised as to why he would want to do that? People ask about being able to automatically load newer version of the assembly with the application or in case of .net being able to load an assembly built with .net framework 1.1 in an application built with .net framework 2.0, but usually not this.

When he explained his situation it made sense. He was working with Sharepoint Server API and there have been some changes in the API between SPS 2003 and 2007. So there was a need to invoke some functionality using SPS 2003 assembly and some functionality using the newer version available with SPS 2007.

I can think of another case where you have programmed against say a buggy assembly and have written some workaround logic for the bug in your code. With the newer version of that assembly that bug has been fixed, but due to some constraints, you can't remove your workaround code and hence can't use the new version. There is however new functionality provided by this new version which you do want to use. Hence you would need to be able to call new methods on new version and the buggy method on the old version.

With this preamble, lets get into how to get this done. There are various permutations and combinations and I will address them. At a high level the solution is in working with one version as already programmed (typically using early binding) and with another version using reflection. Do also note that the assembly loading follows probing rules as defined in .NET SDK documentation. To keep things simple, I will keep the folder path simple and not get into such diversions.

Consider this extremely critical business logic inside of a uniquely named assembly - ClassLibrary1.dll as below. Again to keep things simple, I am not showing the various "using" statements with the code. Additionally to identify which version the method is called on, I return the version# in the string itself. I can do a dynamic query for assembly version and remove this hard coding, but the recall.. our moto is simplicity at this time and focus on loading different versions and not any other aspect, hence the hard coding.

    public class Class1
    {
        public static string Method1()
        {
            return "Method 1 called on version 1.0.0.0";
        }
    }

Then there is this Winform application that invokes this static Method1 and displays the returned string in message box. To help identify if this call has happened due to early binding or reflection, I prefix the string accordingly. I build the code with version 1.0.0.0 of ClassLibrary1.dll and run the application. On invoking the method, I see a message box displaying the appropriate version#. Before we get into multiple versions, a quick discussion of what happens with private as against strong named assemblies is in order.

Weakly named library assembly (privately deployed)

If you update the version of such an assembly and redeploy it with the application, the application is able to load it without any issues. The change in just minor version to 1.1.0.0 or major version also to 2.0.0.0 doens't impact and the application works fine. Note that this is in line with basics of versioning that aren't applicable to weakly named assemblies.

Strongly named library assembly (privately deployed)

If you update the version of such an assembly and redeploy it with the applicaton, the application will give a runtime error when it tries to invoke a method of the library assembly. Due to strong naming, the version policy comes into effect and the application tries to invoked method on version against which it was complied, in this case 1.0.0.0. When it doens't finds this at runtime, it will give an error. It won't automatically start using 1.1.0.0 version. For that you need to specify the
bindingRedirect in the application configuration file.

There are multiple ways to create this configuration file. One is to do this with Visual studio itself and when the application is compiled, the config file is also complied and deployed along wih it. However if you aren't sure of the exact syntax, you can use the Microsoft .NET Framework 2.0 Configuration MMC from Administrators group. Via this you can add the specific application for configuration, then configure the specific library assembly and specify the binding policy. The configuration file generated will look something like this

<?xml version="1.0"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="ClassLibrary1" publicKeyToken="fbc28d9ca2fc8db5" />
        <publisherPolicy apply="no" />
        <bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>


To reiterate, this bindingRedirect is required only for strongly named assemblies. Once this configuration setting is in place, the application is able to load the 1.1.0.0 assembly and invoke methods on it. The same logic will work for assemblies deployed in GAC.

Let us now get on with loading of different versions of the same assembly. See the sample code below on how to achieve it.

        private void btn_Click(object sender, EventArgs e)
        {
            string str = "early bind - ";
            str += ClassLibrary1.Class1.Method1();
            MessageBox.Show(str);
 
            Assembly al = Assembly.LoadFile(@"E:\Temp\old\ClassLibrary1.dll");
 
            Type t = al.GetType("ClassLibrary1.Class1");
            MethodInfo m = t.GetMethod("Method1");
            str = "reflection - " + (string)m.Invoke(null, null);
            MessageBox.Show(str);
        }

When we run the application, we expect the early binding call to go to the newer version and the call via reflection to go to the older version, that we have specifically deployed in another sub-folder. We are using Assembly.LoadFile method so that we can specify a path.

One important aspect to note here is that the application will have to be compiled with the newer version of the assembly if the assembly is strongly named. If that isn't done, as discussed earlier, we will have to use a bindingRedirect configuration setting. Such setting works for all assembly load calls and will even redirect the assembly load call that we are doing via reflection and hence we will not be able to invoke methods on older version. By explicitly building the application with newer version, we don't need to the bindingRedirect configuration setting and our reflection call to earlier version will then work.

Loading assemblies from GAC

There is slight difference in the way the assembly is loaded via reflection if working against GAC. To successfully load different versions from GAC it is best to use the AssemblyName class and specify the FullName of the assembly you want to load. As we all know, FullName includes name, version number, culture and public key token.

        private void btn_Click(object sender, EventArgs e)

        {

            string str = "early bind - ";

            str += ClassLibrary1.Class1.Method1();

            MessageBox.Show(str);

 

            AssemblyName asm = new AssemblyName("ClassLibrary1, Version=1.1.0.0, Culture=neutral, 
                                                                                            PublicKeyToken=fbc28d9ca2fc8db5"
);

            Assembly al = Assembly.Load(asm);

 

            Type t = al.GetType("ClassLibrary1.Class1");

            MethodInfo m = t.GetMethod("Method1");

            str = "reflection - " + (string)m.Invoke(null, null);

            MessageBox.Show(str);

        }

Needless to say that it also possible to load as many versions as you want using the option of reflection and you need not invoke any version via early binding. I have used to early binding option just to highlight a case where you are already working with a version and want to also specifically invoke methods on a different version. This also means that you can early bind to an older version and load the newer version by reflection.

While playing around with this, I also realized that one needs not worry about references added to the project. The compiler is intelligent enough to add them to the manifest only if a call is made to any method contained in the referenced assembly. If no call is made, the reference isn't included and hence the assembly won't be loaded at run time. You can easily verify this by viewing the manifest via ILDasm utility.