Monday, February 28, 2011

Breakpoints are not working in visual studio?

If are you getting the warning "The break point will not currently be hit. No symbols have been loaded for this document." If breakpoints stopped working in the project on vs IDE the breakpoints became hollow circle with a warning message inside both VS 2008 and Vs 2005, below are few points that comes handy when you break points stop working on Visual Studio.







--> First of all check whether you are running on debug or release mode if you are running on release mode change it to debug, if it is in debug try next step.


--> Go to Debug-->Windows-->Modules check whether all the project dll's have symbol status if it says cannot find or open pdb file right click on module select load symbols and browse to the path of your application PDB,if it says says symbol Loaded then try next point.

--> Exit your IDE and delete bin and obj folder go to visual studio command line and run "devenv /resetsettings" NOTE: running this command will reset all your visual studio settings to default so think before running it and use at your own risk.

--> If you are using web development then Clear temporary output folders the path looks something like below

C:\WINDOWS\Microsoft.NET\Framework\{framework version}\Temporary ASP.NET Files\{some name}\{some numbers}\{some numbers} 

Friday, February 25, 2011

Introduction to Visual Studio IDE with features

Visual Studio .NET IDE

Visual Studio .NET IDE (Integrated Development Environment) is the Development Environment for all .NET based applications which comes with rich features. VS .NET IDE provides many options and is packed with many features that simplify application development by handling the complexities. Visual Studio .NET IDE is an enhancement to all previous IDE’s by Microsoft.

Important Features

One IDE for all .NET Projects

Visual Studio .NET IDE provides a single environment for developing all types of .NET applications. Application’s range from single windows applications to complex n-tier applications, rich web applications, Web Services, Windows Services, Mobile applications, Console Applications etc.,


Option to choose from Multiple Programming Languages

You can choose the programming language of your choice to develop applications based on your expertise in that language. The major programming languages supported by the Visual Studio are C#, VB.Net, F#, J#, C++ etc., You can also incorporate multiple programming languages in one .NET solution and edit that with the IDE.


Option to choose from Multiple Frameworks

You can choose a specific framework to develop the project for your specific target platform. Also you can have multiple projects with multiple frameworks under single solution.


IDE is Customizable

You can customize the IDE based on your preferences. The Options under Tools menu settings allow you to do this. With these settings you can set the IDE screen the way you want, the way the keyboard behaves and you can also filter the help files based on the language of your choice. You can select fonts, colors of your coding window.
You can also change the Text Editor properties for various languages. If you want to store your settings you can Import and Export your settings.


Built-in Browser

The IDE comes with a built-in browser that helps you browse the Internet without launching another application. You can look for additional resources, online help files, source codes and much more with this built-in browser feature.
When we open VS .NET from Start->Programs->Microsoft Visual Studio .NET->Microsoft Visual Studio .NET the window that is displayed first is the Start Page which is shown below. The start Page allows us to select from the most recent projects (last four projects) with which we worked or it can be customized based on your preferences.




The Integrated Development Environment (IDE) shown in the image below is what we actually work with. This IDE is shared by all programming languages in Visual Studio. You can view the toolbars towards the left side of the image along with the Solution Explorer window towards the right.





New Project Dialogue Box

The New Project dialogue box like the one in the image below is used to create a new project specifying it's type allowing us to name the project and also specify it's location on the disk where it is saved. The default location on the hard disk where all the projects are saved is C:\DocumentsandSettings\Administrator\MyDocuments\VisualStudioProjects.




Following are different templates under Project Types and their use:

Windows Application: This template allows you to create standard windows based applications.
Class Library: Class libraries are those that provide functionality similar to Active X and DLL by creating classes that access other applications.
Windows Control Library: This allows you to create our own windows controls. Also called as User Controls, where you group some controls, add it to the toolbox and make it available to other projects.
ASP .NET Web Application: This allows you to create web-based applications using IIS. We can create web pages, rich web applications and web services.
ASP .NET Web Service: Allows you to create XML Web Services.
Web Control Library: Allows you to create User-defined controls for the Web. Similar to user defined windows controls but these are used for Web.
Console Application: A new kind of application in Visual Studio .NET. They are command line based applications.
Windows Service: These run continuously regardless of the user interaction. They are designed for special purpose and once written, will keep running and come to an end only when the system is shut down.
Other: This template is to develop other kinds of applications like enterprise applications, database applications, Setup and Deployment etc.



Solution Explorer Window

Solution Explorer provides you with an organized view of your projects and their files as well as ready access to the commands that pertain to them. A toolbar associated with this window offers commonly used commands for the item you highlight in the list. To access Solution Explorer, select Solution Explorer on the View menu. An image of the Solution Explorer window is shown below.





Server Explorer Window

The Server Explorer window is a great tool that provides "drag and drop" feature and helps us work with databases in an easy graphical environment. For example, if we drag and drop a database table onto a form, VB .NET automatically creates connection and command objects that are needed to access that table. The image below displays Server Explorer window.





Class View

Class View displays the symbols defined, referenced, or called in the application you are developing. You can open Class View from the View menu. There are two panes: an upper Objects pane and a lower Members pane. The Objects pane contains an expandable tree of symbols whose top-level nodes represent projects. To expand a node selected in the tree, click its plus (+) sign or press the plus (+) key on the keypad.





Intellisense

Intellisense is what that is responsible for the boxes that open as we type the code. IntelliSense provides a list of options that make language references easily accessible and helps us to find the information we need. They also complete the typing for us. The image below displays that.
IntelliSense provides an array of options that make language references easily accessible. When coding, you do not need to leave the Code Editor or the Immediate Mode command window to perform searches on language elements. You can keep your context, find the information you need, insert language elements directly into your code, and even have IntelliSense complete your typing for you.

IntelliSense comprises the following options:
  • List Members
  • Parameter Info
  • Quick Info
  • Complete Word
  • Automatic Brace Matching



Properties Window

The properties window allows us to set properties for various objects at design time. For example, if you want to change the font, font size, backcolor, name, text that appears on a button, textbox etc, you can do that in this window. Below is the image of properties window. You can view the properties window by selecting
View->Properties Window from the main menu or by pressing F4 on the keyboard.





Code Definition Window

The Code Definition window is a read-only editor view that displays the definition of a symbol in a code file stored in, or referenced by, the active project. To display this window, select Code Definition Window from the View menu. When the window first opens, it displays the definition for the last symbol selected. If no definition is available, No definition selected is displayed. This window can be docked along any convenient edge of the integrated development environment (IDE). By default, it is displayed beneath the Code Editor.





Command Window

The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.

You can view the command window by selecting 
View->Other Windows->Command Window from the main menu. The command window in the image displays all possible commands with File.




Output Window
This window can display status messages for various features in the integrated development environment (IDE). It displays the results of building and running applications. To display the Output window, select Output from the View menu. To close the Output window and shift focus back to the Editor, press the Escape (ESC) key.




Object Browser

The Object Browser allows you to select and examine the symbols available for use in projects. You can open the Object Browser from the View menu, or by clicking the Object Browser button on the main toolbar.
There are three panes: an Objects pane on the left, a Members pane on the upper right, and a Description pane on the lower right. If you resize the Object Browser into a single column, the Objects pane moves to the top, the Members pane to the middle, and the Description pane to the bottom.
In the Objects pane, icons identify hierarchical structures such as .NET Framework and COM components, namespaces, type libraries, interfaces, enums, and classes. You can expand these structures to reveal ordered lists of their members. Properties, methods, events, variables, constants, and other contained items are listed in the Members pane. Details on the item selected in the Objects or Members pane appear in the Description pane.
You can view the object explorer window by selecting View->Other Windows-> Object Browser from the main menu.





Error List Window

The Error List helps you speed application development. In the Error List window, you can:
  • Display the Errors, Warnings, and Messages produced as you edit and compile code.
  • Find syntax errors noted by IntelliSense.
  • Find deployment errors, certain Static Analysis errors, and errors detected while applying Enterprise Template policies.
  • Double-click any error message entry to open the file where the problem occurs, and move to the error location.
  • Filter which entries are displayed, and which columns of information appear for each entry.
To display the Error List, on the View menu choose Error List.
Use the Errors, Warnings, and Messages buttons to select which entries to display.





Call Stack Window

By using the Call Stack window, you can view the function or procedure calls that are currently on the stack.
The Call Stack window displays the name of each function and the programming language it is written in. The function or procedure name may be accompanied by optional information, such as module name, line number, byte offset, and parameter names, types, and values. The display of this optional information can be turned on or off.




Watch Window
You can use the Watch window to evaluate variables and expressions and keep the results. You can also use the Watch window to edit the value of a variable or register.
To open the Watch window, the debugger must be running or in break mode. From the Debug menu, choose Windows, then Watch, and click on Watch1, Watch2, Watch3, or Watch4.





Task List Window

The Task List helps you create and manage a list of programming tasks. In the Task List window, you can:
  • Enter notes on work to be done as User Tasks. For more information.
  • Display Task Comments that link to lines in your code files where work must be done. For more information
  • Display custom Categories of task messages.
To display the Task List, on the View menu, click Task List. Use the Categories drop-down list to select which entries to display.





Thursday, February 24, 2011

Basics of .Net Framework and Interview Questions

What is the .NET Framework?
The .NET Framework is a new and revolutionary platform created by Microsoft for developing applications.
  • It is a platform for application developers.
  • It is a Framework that supports Multiple Language and Cross language integration.
  • IT has IDE (Integrated Development Environment).
  • Framework is a set of utilities or can say building blocks of your application system.
  • .NET Framework provides GUI in a GUI manner.
  • .NET is a platform independent but with help of Mono Compilation System (MCS). MCS is a middle level interface.
  • .NET Framework provides interoperability between languages i.e. Common Type System (CTS) .
  • .NET Framework also includes the .NET Common Language Runtime (CLR), which is responsible for maintaining the execution of all applications developed using the .NET library.
  • The .NET Framework consists primarily of a gigantic library of code.
Cross Language integration

You can use a utility of a language in another language (It uses Class Language Integration).

.NET Framework includes no restriction on the type of applications that are possible. The .NET Framework allows the creation of Windows applications, Web applications, Web services, and lot more.

The .NET Framework has been designed so that it can be used from any language, including C#, C++, Visual Basic, JScript, and even older languages such as COBOL.


It is a Framework in which Windows applications may be developed and run.

The Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications. The .NET Framework consists of three main parts: the common language runtime, a hierarchical set of unified class libraries, and a componentized version of Active Server Pages called ASP.NET. 

The .NET Framework provides a new programming model and rich set of classes designed to simplify application development for Windows, the Web, and mobile devices. It provides full support for XML Web services, contains robust security features, and delivers new levels of programming power. The .NET Framework is used by all Microsoft languages including Visual C#, Visual J#, and Visual C++.






.Net Code Compilation and Execution process





What is "Common Type System" (CTS)?
CTS describes how types are declared used and managed in the runtime and facilitates cross-language integration type safety and high performance code execution. Common type system brings all .Net languages data types on a common platform.


What is "Common Language Runtime" (CLR)?
Common Language Runtime - It is the implementation of CLI. The core runtime engine in the Microsoft .NET Framework for executing applications. The common language runtime supplies managed code with services such as cross-language integration, code access security, object lifetime management, resource management, type safety, pre-emptive threading, metadata services (type reflection), and debugging and profiling support. The ASP.NET Framework and Internet Explorer are examples of hosting CLR. 
The CLR is a multi-language execution environment. The CLR is described as the "execution engine" of .NET. It's this CLR that manages the execution of programs. It provides the environment within which the programs run. The software version of .NET is actually the CLR version. 


When the .NET program is compiled, the output of the compiler is not an executable file but a file that contains a special type of code called the Microsoft Intermediate Language (MSIL, now called CIL, Common Intermediate Language). This MSIL defines a set of portable instructions that are independent of any specific CPU. It's the job of the CLR to translate this Intermediate code into a executable code when the program is executed making the program to run in any environment for which the CLR is implemented. And that's how the .NET Framework achieves Portability. This MSIL is turned into executable code using a JIT (Just In Time) complier. The process goes like this, when .NET programs are executed, the CLR activates the JIT complier. The JIT complier converts MSIL into native code on a demand basis as each part of the program is needed. Thus the program executes as a native code even though it is compiled into MSIL making the program to run as fast as it would if it is compiled to native code but achieves the portability benefits of MSIL.


It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately.

The CLR is the execution engine for .NET Framework applications. It provides a number of services, including:

·          Code management (loading and execution)
·          Application memory isolation
·          Verification of type safety
·          Conversion of IL to native code.
·          Access to metadata (enhanced type information)
·          Managing memory for managed objects
·          Enforcement of code access security
·          Exception handling, including cross-language exceptions
·          Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data)
·          Automation of object layout
·          Support for developer services (profiling, debugging, and so on).


What is "Microsoft Intermediate Language" (MSIL)?
A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL - since our source code in automatically converted to MSIL. The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language, which is, then run on the host machine. MSIL is similar to Java Byte code.
MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.

Combined with metadata and the common type system, MSIL allows for true cross- language integration Prior to execution, MSIL is converted to machine code. It is not interpreted.



What is "Common Language Specification" (CLS)?
CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow. It is a subsection of CTS and it specifies how it shares and extends one another libraries.

What is the basic functionality of Garbage Collector in .Net?

The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.

Here are the list of some tasks performed by the Garbage collector:
  • Garbage collector reserves a piece of memory as the application starts for the managed heap.
  • Garbage collector controls the managed heap memory currently used and available to an application.
  • Garbage collector allocates memory for new objects within the application.
  • The Garbage Collector attempts to reclaim the memory of objects that are not referenced.


Which versions of .NET have been released so far with their features:

Version
Version Number
Release Date
Visual Studio
Default in Windows
1.0
1.0.3705.0
2002-02-13
Visual Studio .NET

1.1
1.1.4322.573
2003-04-24
Visual Studio .NET 2003
Windows Server 2003
2.0
2.0.50727.42
2005-11-07
Visual Studio 2005
Windows Server 2003 R2
3.0
3.0.4506.30
2006-11-06

Windows Vista, Windows Server 2008
3.5
3.5.21022.8
2007-11-19
Visual Studio 2008
Windows 7, Windows Server 2008 R2
4.0
4.0.30319.1
2010-04-12
Visual Studio 2010



.Net Framework 1.0

This is the first release of the .NET Framework, released on 13 February 2002 and available for Windows 98, Me, NT 4.0, 2000, and XP. Mainstream support by Microsoft for this version ended 10 July 2007, and extended support ended 14 July 2009.


.Net Framework 1.1

This is the first major .Net Framework upgrade. It is available on its own as a redistributable package or in a software development kit, and was published on 3rd April 2003. It is also part of the second release of Microsoft Visual Studio .Net (released as Visual Studio .Net 2003)

Changes in 1.1 in comparison with 1.0

  • Built-in support for mobile ASP.NET controls. Previously available as an add-on for .NET Framework, now part of the framework.
  • Security changes – enable Windows Forms assemblies to execute in a semi-trusted manner from the Internet, and enable Code Access Security in ASP.NET applications.
  • Built-in support for ODBC and Oracle databases. Previously available as an add-on for .NET Framework 1.0, now part of the framework.
  • .NET Compact Framework – a version of the .NET Framework for small devices.
  • Internet Protocol version 6 (IPv6) support.
  • Numerous API changes.


.NET Framework 2.0
Released with Visual Studio 2005, Microsoft SQL Server 2005, and BizTalk 2006.
The 2.0 Redistributable Package can be downloaded for free from Microsoft, and was published on 22 January 2006.


Changes in 2.0 in comparison with 1.1

  • Generics 
  • Language support for generics built directly into the .NET CLR. 
  • Full 64-bit support for both the x64 and the IA64 hardware platforms. 
  • Numerous API changes. 
  • SQL Server integration – .NET 2.0, VS 2005, and SQL Server 2005 are all tied together. This means that instead of using T-SQL, one can build stored procedures and triggers in any of the .NET-compatible languages. 
  • A new hosting API for native applications wishing to host an instance of the .NET runtime. The new API gives a fine grain control on the behavior of the runtime with regards to multi threading, memory allocation, assembly loading and more (detailed reference). It was initially developed to efficiently host the runtime in Microsoft SQL Server, which implements its own scheduler and memory manager. 
  • Many additional and improved ASP.NET web controls. 
  • New data controls with declarative data binding. 
  • New personalization features for ASP.NET, such as support for themes, skins, master pages and web parts. 
  • .NET Micro Framework – a version of the .NET Framework related to the Smart Personal Objects Technology initiative. 
  • Membership provider 
  • Partial classes 
  • Nullable types 
  • Anonymous methods 
  • Iterators 
  • Data tables 

.NET Framework 3.0
.NET Framework 3.0, formerly called WinFX, was released on 21 November 2006. It includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems. It is also available for Windows XP SP2 and Windows Server 2003 as a download. There are no major architectural changes included with this release; .NET Framework 3.0 uses the Common Language Runtime of .NET Framework 2.0. Unlike the previous major .NET releases there was no .NET Compact Framework release made as a counterpart of this version. Version 3.0 of the .NET Framework shipped with Windows Vista. It also shipped with Windows Server 2008 as an optional component (disabled by default).
.NET Framework 3.0 consists of four major new components:
  • Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies. See WPF SDK for developer articles and documentation on WPF. 
  • Windows Communication Foundation (WCF), formerly code-named Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services. 
  • Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows. 
  • Windows CardSpace, formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website.

NET Framework 3.5
Version 3.5 of the .NET Framework was released on 19 November 2007, but it is not included with Windows Server 2008. As with .NET Framework 3.0, version 3.5 uses the CLR of version 2.0. In addition, it installs .NET Framework 2.0 SP1, (installs .NET Framework 2.0 SP2 with 3.5 SP1) and .NET Framework 3.0 SP1 (installs .NET Framework 3.0 SP2 with 3.5 SP1), which adds some methods and properties to the BCL classes in version 2.0 which are required for version 3.5 features such as Language Integrated Query (LINQ).

Changes since version 3.0

  • New language features in C# 3.0 and VB.NET 9.0 compiler
  • Adds support for expression trees and lambda methods
  • Extension methods
  • Expression trees to represent high-level source code at runtime.
  • Anonymous types with static type inference
  • Language Integrated Query (LINQ) along with its various providers
  • LINQ to Objects
  • LINQ to XML
  • LINQ to SQL
  • Paging support for ADO.NET
  • ADO.NET synchronization API to synchronize local caches and server side data stores
  • Asynchronous network I/O API.
  • Peer-to-peer networking stack, including a managed PNRP resolver
  • Managed wrappers for Windows Management Instrumentation and Active Directory API’s
  • Enhanced WCF and WF runtimes, which let WCF work with POX and JSON data, and also expose WF workflows as WCF services. WCF services can be made stateful using the WF persistence model. Support for HTTP pipelining and syndication feeds.
  • ASP.NET AJAX is included.

.NET Framework 4
On 12 April 2010, the final version of .NET Framework 4.0 was launched alongside the final release of Visual Studio 2010.

Key focuses for this release are:
  • Parallel Extensions to improve support for parallel computing, which target multi-core or distributed systems. To this end, they included technologies like PLINQ (Parallel LINQ), a parallel implementation of the LINQ engine, and Task Parallel Library, which exposes parallel constructs via method calls.
  •  New Visual Basic .NET and C# language features, such as statement lambdas, implicit line continuations, dynamic dispatch, named parameters, and optional parameters.
  • Support for Code Contracts.
  • Inclusion of new types to work with arbitrary-precision arithmetic (System.Numerics.BigInteger) and complex numbers (System.Numerics.Complex).

What is encapsulation?
Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality. 

What is Overloading?

When we add a new method with the same name in a same/derived class but with different number/types of parameters, the concept is called overload and this ultimately implements Polymorphism. 

What is overriding?

When we need to provide different implementation in a child class than the one provided by base class, we define the same method with same signatures in the child class and this is called overriding.


What is managed data?
The data for which the memory management is taken care by .Net runtime’s garbage collector, and this includes tasks for allocation de-allocation.


What is Multi-tasking?
It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time. 

What is Multi-threading?

When an application performs different tasks at the same time, the application is said to exhibit multithreading as several threads of a process are running.