Great India Shopping

Saturday, June 23, 2012

Windows Communication Foundation basics

Windows Communication Foundation(WCF) is a programming platform for building, configuring and deploying network-distributed services.It is one of the latest service oriented technologies developed by Microsoft to enhancing the capabilities of already present web services.WCF services are interoperable.WCF is a combinationn of 5 different technologies - Web Service, WSE(Web Service Enhancements),Remoting, MSMQ and COM+.

Though building WCF services requires thorough understanding of .NET Framework as well as SOA architecture,there are many advantages provided by WCF services.

-> WCF services are more advanced comapred to age old web service technology in many ways including the protocol support,reliability and security.

-> WCF services are more interoperable compared to the web services.They can be used across frameworks and technologies.

-> WCF can be used todesign more reliable services including the MSMQ capacity, where your message is more reliably delivered to the user even after the connection is lost for few minutes.

-> WCF services are highly configuration based.You can make enormous changes in the services by changing a small configuration in the service, which makes developer work more easy.

Tuesday, March 8, 2011

Error:Object Reference Not Found in .Net

Hi,
This is one error which every .Net developer might have faced at some point of his coding life. I provide 1 reason/ scenario when this error would occur.
Example :
1) when your session object becomes null and you have tried to assign it to another variable.
session["username"] = null ;
string myusername;
myusername = session["username"].ToString();
Here in the last statement when CLR tries to get a string value of a session object , no value is found in it. So it throws an "Object Reference Not Found" error.
Solution : Check your session objects for null values.
This is 1 scenario I encountered.I will keep hitting this post when I face other scenarios where the same error occurs.
Happy Coding !!

Sunday, August 2, 2009

Microsoft Visual studio 2010 and .NET 4.0 CTP features and download link

Hi folks.Try out the latest release of microsoft visual studio 2010 and .NET 4.0 CTP release .Visual studio has many enhanced features ,which include
 1) Enhanced  User experience providing better support for floating documents and windows.Enhanced document targeting and improved animation support
2) Parallel Programming providing IDE support and native C++ libraries that use lambda functions.Resource management of hardware and parallel debugging views as well as windows are provided.
3) Better Application Lifecycle management which helps you to design and share multiple digram types of usecase and sequence diagrams.It also provides better tooling for documentation of test scenarios and includes a new Test Impact View.
4) It provides C++ development experience which helps developers navigate and understand complex C++ source code.
5) For web development it has enriched Javascript Intellisense,one click deployment and full support for silverlight
6) Windows Azure tools for visual studio provides C# and VB templates for building cloud services,tools to change service role configuration and building packages of cloud services
7)Multiple database support which helps Developers to work with IBM DB2 and Oracle in adition to SQL Server

The download link is Get Visual Studio 2010 Files from Here

Layouts in Windows Presenation Foundation(wpf)

In this post let me give you a detailed view of Layout controls in WPF.
Layout Principles
The developers of WPF knew that layout was going to be an intrinsic part of the system. The goal was to define a single layout system that could span from
paginated documents to traditional application UIs. Eventually we realized that a single, monolithic system for this wide span of scenarios was impossible (or at least very difficult) and moved to a model of layout composition. We ended up solving the bulk of the layout problems in the same way that we tackled the control library: by allowing layouts to be nested inside of other layouts.
Given this approach, it seemed that the most critical thing to determine was how a child control would communicate with the parent layout. This “contract” between the parent and child would, we hoped, enable any control to be hosted in any layout.
Layout Library
On top of the basic layout control and the more complete framework layout odel, WPF provides a suite of layout panels. These panels implement set of basic layouts that tries to represent the most common needs for layout. e will cover some of the more common layout panels: Canvas, tackPanel, DockPanel, and UniformGrid. The most complex layout, Grid, will be covered next, in a section all to itself.
1) Canvas
Canvas is the simplest layout included in WPF. Canvas offers four properties:Top, Left, Right, and Bottom. Canvas lets us position its child elements at any offset from one corner of the panel. Notice that I said “position”; Canvas does not introduce any sizing constraints on child elements. Canvas simply takes the desired size from an element and positions it relative to one of the four corners. Only two properties can be used: one horizontal coordinate and one vertical coordinate. If more are specified, the extra properties will be ignored.
Canvas doesn’t place any interesting constraints on the width or height of the layout slot, so the HorizontalAlignment and VerticalAlignment properties are irrelevant. Margins are still honored, but they are behaviorally identical to setting the Canvas layout properties. For this reason, Canvas is sometimes referred to as the “slotless” layout panel.
2) StackPanel
Up to this point in the article, StackPanel is the only layout panel that we’ve seen, so you’ve probably figured out how it works by now, but it’s still useful to talk about it. As the name implies, StackPanel stacks things up in a row. Through the Orientation property we can control whether the stack is horizontal or vertical.
The slot for each child in StackPanel is given the entire width or height of the control (depending on its orientation), and StackPanel determines its preferred size according to the maximum size of its children. To show this, we can nest a couple of StackPanel controls and see how they behave. The outermost instance has a border around it (so that it’s visible), and each inner panel has a background:
StackPanel must be used carefully because it measures children using an infinite width or height based on the orientation. This lack of a control on size can break other child layout panels, specifically causing problems for TextBlock with wrapping.
3) DockPanel
DockPanel is fairly similar to StackPanel, except that it allows mixing of stacking from different edges within the same layout container.
DockPanel is probably one of the most common UI layouts today. Windows Forms natively supported docking, and Java supports docking with its BorderLayout class. Docking allows elements to be stacked at any edge of a container, with the final element filling the remaining space.
We can break down Windows Explorer into its major structural elements: menu, toolbar, folder list, and details pane .Implementing this layout in WPF is relatively simple: The DockPanel offers a single property, Dock, which allows us to specify the edge to which a control is docked. The declaration order of the elements determines the order in which they’re placed, and by default the last child fills the remaining space.
4) WrapPanel
If DockPanel is a stack panel with multiple edges, then WrapPanel is a stack panel with wrapping support. Remember that StackPanel positions elements with infinite width or height (depending on the orientation), allowing any number of elements, stacked one after the other. WrapPanel, on the other hand, uses the available space and fits elements to it; and when it runs out of room, it wraps to the next line. The classic example of a wrappanel is toolbar layouts.
By default, WrapPanel simply sizes all the children to fit their content, although we can fix the width and height of the children by using the ItemWidth and ItemHeight properties:

5) UniformGrid
The final basic layout, which is really nothing like StackPanel, is UniformGrid. UniformGrid hides in the System.Windows.Controls.Primitives namespace and provides a very basic grid layout: Each cell is the same size (hence uniform), and the locations of the items are determined simply by their order in the children collection.
To use UniformGrid, we specify the number of columns and rows we want. If we specify only columns, then rows will be calculated as the number of children divided by the number of columns, and vice versa.
6) Grid
UniformGrid offers a basic grid, but for most scenarios it doesn’t go far enough. People want grids with items that span cells, nonuniform row and column spacing, and so on. Grid is by far the most power, flexible, and complex of the UI layouts. On the surface, Grid is simple: Elements are positioned within grid cells defined by a series of rows and columns. Easy, right?
The simplest use of Grid is to set the RowDefinitions and Column- Definitions properties, add some children, and use the Grid.Row and Grid.Column attached properties to specify which child goes in which slot :

We will see different WPF controls in the next article on WPF Controls

Basic XAML(Extensible Aplication Markup Language)

In this post we will have a brief overview of XAML nad its usage in WPF
One of the primary objectives of WPF was to bring together the best features of both Windows development and the Web model. Before we look at the features of WPF, it is important to understand the new programming model in the .NET Framework 3.0: XAML.

A Brief Look at the XAML Programming Model

One of the major, and often misunderstood, features of .NET 3.0 is the new XAML programming model. XAML provides a set of semantics on top of raw XML that enables a common interpretation. To oversimplify slightly,XAML is an XML-based instantiation script for CLR objects. There is a mapping from XML tags to CLR types, and from XML attributes to CLR properties and events. The following example shows an object being created and a property being set in both XAML and C#:

// C# version
MyObject obj = new MyObject();
obj.SomeProperty = 1;

XAML was created to be a markup language that integrated well with the CLR and provided for rich tool support. A secondary goal was to create a markup format that was easy to read and write. It may seem a little rude to design a feature of the platform that is optimized first for tools, then for humans, but the WPF team felt strongly that WPF applications would typically be authored with the assistance of a visual design tool like Microsoft Visual Studio or Microsoft Expression. To walk the line between tools and humans, WPF allows the type author to define one property to be the content property.

For further readability, XAML has a feature known as markup extensions. This is a general way to extend the markup parser to produce simpler markup. Markup extensions are implemented as CLR types, and they work almost exactly like CLR attribute definitions. Markup extensions are enclosed in curly braces, { }. For example, to set a property value to the special value null, we can use the built-in Null markup extension:

In the next post we will see the layouts in WPF and their usage in detail.

Starting Windows Presentation Foundation(Basics)

Starting with WPF Layouts here, we will move on to cover entire WPF in the next coming articles.Here i am posting basic WPF information and details of WPF Layouts.

WINDOWS PRESENTATION FOUNDATION (WPF) represents a major step forward in user interface technology. This chapter will lay out some of the basic principles of WPF and walk through a quick overview of the entire platform. You can think of this chapter as a preview of the rest of the book.
A primary goal of WPF is to preserve as much developer knowledge as possible. Even though WPF is a new presentation system completely different from Windows Forms, we can write the equivalent program in WPF with very similar code1 (changes are in boldface):
/* sample code */
using System.Windows;using System;
class Program {[STAThread]static void Main()
{Window f = new Window();f.Title = "Hello World";new Application().Run(f);}}
In both cases the call to Run on the Application object is the replacement for the message loop, and the standard CLR (Common Language Runtime) type system is used for defining instances and types. Windows Forms is really a managed layer on top of User32, and it is therefore limited to only the fundamental features that User32 provides.
User32 is a great 2D widget platform. It is based on an on-demand, clipbased painting system; that is, when a widget needs to be displayed, the system calls back to the user code (on demand) to paint within a bounding box that it protects (with clipping). The great thing about clip-based painting systems is that they’re fast; no memory is wasted on buffering the content of a widget, nor are any cycles wasted on painting anything but the widget that has been changed.
The downsides of on-demand, clip-based painting systems relate mainly to responsiveness and composition. In the first case, because the system has to call back to user code to paint anything, often one component may prevent other components from painting. This problem is evident in Windows when an application hangs and goes white, or stops painting correctly. In the second case, it is extremely difficult to have a single pixel affected by two components, yet that capability is desirable in many scenarios—forexample, partial opacity, anti-aliasing, and shadows.
WPF is based on a retained-mode composition system. For each component a list of drawing instructions is maintained, allowing for the system to automatically render the contents of any widget without interacting with user code. In addition, the system is implemented with a painter’s algorithm, which ensures that overlapping widgets are painted from back to front, allowing them to paint on top of each other. This model lets the system manage the graphics resource, in much the same way that the CLR manages memory, to achieve some great effects. The system can perform high-speed animations, send drawing instructions to another machine, or even project the display onto 3D surfaces—all without the widget being aware of the complexity. In WPF’s composition engine, all controls are contained, grouped, and composited. A button in WPF is actually made up of several smaller controls. This move to embrace composition, coupled with a vector-based approach, enables any level of containment.In addition to addressing the limitations of User32 and GDI32, one of WPF’s goals was to bring many of the best features from the Web programming model to Windows developers.
HTML, a.k.a. the Web
One of the biggest assets of Web development is a simple entry to creating content. The most basic HTML “program” is really nothing more than a few HTML tags in a text file:
--Hello World

Welcome to my document!
--


In fact, all of the tags can be omitted, and we can simply create a file with the text “Welcome to my document!”, name it .html, and view it in a browser This amazingly low barrier to entry has made developers out of millions of people who never thought they could program anything. In WPF we can accomplish the same thing using a new markup format called XAML (Extensible Application Markup Language), pronounced “zammel.” Because XAML is a dialect of XML, it requires a slightly stricter syntax. Probably the most obvious requirement is that the xmlns directive must be used to associate the namespace with each tag:
In WPF we can accomplish the same thing using a new markup format called XAML (Extensible Application Markup Language), pronounced “zammel.” Because XAML is a dialect of XML, it requires a slightly stricter syntax. Probably the most obvious requirement is that the xmlns directive must be used to associate the namespace with each tag:

Parallel Query Run and steps to Fix I/O Bottlenecks in Sql Server

In this post let me give you a brief description of problems of parallel query run and counters and other statistics that help us find the performance problems of parallel query run .Finally i will tell you 6 single line steps to fix I/O bottlenecks of performance in SQL Server.
Parallel Query Run:
If the query’s cost exceeds the value specified in the cost threshold for parallelism option then the optimizer attempts to generate a plan that can be run in parallel. A parallel query plan uses multiple threads to process the query. The maximum degree of parallelism can be limited server wide using the MAXDOP option.
The decision on the actual degree of parallelism (DOP) used for execution—a measure of how many threads will do a given operation in parallel—is deferred until execution time. A parallel query typically uses a similar but slightly higher amount of CPU time as compared to the corresponding serial execution plan, but it does so in a shorter duration of elapsed time. As long as there are no other bottlenecks, such as waits for physical I/O, parallel plans generally should use 100% of the CPU across all of the processors.
Look at the SQL Server: SQL Statistics – Batch Requests/sec counter.Because a query must have an estimated cost that exceeds the cost threshold for the parallelism configuration setting (which defaults to 5) before it is considered for a parallel plan, the more batches a server is processing per second the less likely it is that the batches are running with parallel plans.The plan can be retrieved using sys.dm_exec_cached_plan.We may also search for plans that are eligible to run in parallel by searching the cached plans to see if a relational operator has its Parallel attribute as a nonzero value.
Steps to fix I/O Bottlenecks
1) Check the memory configuration of SQL Server. If SQL Server has been configured with insufficient memory, it will incur more I/O overhead.
2) Buffer Cache hit ratio
3) Page Life Expectancy
4) Checkpoint pages/sec
5) Lazy writes/sec
6) Increase I/O bandwidth.

We will discuss these 6 steps in detail in the next post and let me research on them by that.Bye for Now.