Thursday, November 12, 2009

New features in VS 2008

• Multi-Targeting support
• Javascript Intellisense
• Javascript debugging
• Code editing improvements
• Nested Master Page support
• Web designer and CSS improvements
• New Split View including vertical split
• Enhanced support for the ASP.NET AJAX Extensions
• LINQ to SQL designer
• Enhanced XML support
• Support for Silverlight
• Support for WPF
• Support for debugging .NET Framework 3.5 class libraries

Monday, September 7, 2009

What are HTTP Handlers?

HTTP handlers are the .NET components that implement the System.Web.IHttpHandler interface, they can act as a target for the incoming HTTP requests and can be called directly by using their file name in the URL.

HTTP handlers implement the following two methods:
1) ProcessRequest: called to process http requests and
2) IsReusable which indicates whether this instance of http handler can be reused for fulfilling another requests of the same type.

Sunday, April 19, 2009

Auto-Start Web Applications IN ASP.NET 4.0


Some Web applications need to load large amounts of data or perform expensive initialization processing before serving the first request. In earlier versions of ASP.NET, for these situations you had to devise custom approaches to "wake up" an ASP.NET application and then run initialization code during the Application_Load method in the Global.asax file.
A new scalability feature named auto-start that directly addresses this scenario is available when ASP.NET 4.0 runs on IIS 7.5 on Windows Server 2008 R2. The auto-start feature provides a controlled approach for starting up an application pool, initializing an ASP.NET application, and then accepting HTTP requests.
To use the auto-start feature, an IIS administrator sets an application pool in IIS 7.5 to be automatically started by using the following configuration in the applicationHost.config file:


Because a single application pool can contain multiple applications, you specify individual applications to be automatically started by using the following configuration in the applicationHost.config file:

When an IIS 7.5 server is cold-started or when an individual application pool is recycled, IIS 7.5 uses the information in the applicationHost.config file to determine which Web applications need to be automatically started. For each application that is marked for auto-start, IIS7.5 sends a request to ASP.NET 4.0 to start the application in a state during which the application temporarily does not accept HTTP requests. When it is in this state, ASP.NET instantiates the type defined by the preloadProvider attribute (as shown in the previous example) and calls into its public entry point.
You create a managed auto-start type with the necessary entry point by implementing the IProcessHostPreloadClient interface, as shown in the following example:
public class CustomInitialization : System.Web.Hosting.IProcessHostPreloadClient
{
public void Preload(string[] parameters)
{
// Perform initialization.
}
}
After your initialization code runs in the Preload method and the method returns, the ASP.NET application is ready to process requests.
With the addition of auto-start to IIS 7.5 and ASP.NET 4.0, you now have a well-defined approach for performing expensive application initialization prior to processing the first HTTP request. For example, you can use the new auto-start feature to initialize an application and then signal a load-balancer that the application was initialized and ready to accept HTTP traffic.




Thursday, March 19, 2009

The current transaction cannot be committed when using service broker

The current transaction cannot be committed when using service broker
=================================================================
when we use service broker queue to comunicate biztalk and sql sever we might get error meaasgae in some cases.To avoid this use xact_state(). Is a scalar function that reports the user transaction state of a current running request. XACT_STATE indicates whether the request has an active user transaction, and whether the transaction is capable of being committed.
The current request has an active user transaction. The request can perform any actions, including writing data and committing the transaction.

1 - The current request has an active user transaction. The request can perform any actions, including writing data and committing the transaction.
0 - There is no active user transaction for the current request.
-1 - The current request has an active user transaction, but an error has occurred that has caused the transaction to be classified as an uncommittable transaction. The request cannot commit the transaction or roll back to a savepoint; it can only request a full rollback of the transaction.
SET XACT_ABORT ON;
BEGIN TRY
BEGIN TRANSACTION;
-- A FOREIGN KEY constraint exists on this table. This
-- statement will generate a constraint violation error.
DELETE FROM Production.Product WHERE ProductID = 980;
-- If the delete operation succeeds, commit the transaction. The CATCH
-- block will not execute.
COMMIT TRANSACTION;
END TRY
BEGIN CATCH
-- Test XACT_STATE for 0, 1, or -1.
-- If 1, the transaction is committable.
-- If -1, the transaction is uncommittable and should
-- be rolled back.
-- XACT_STATE = 0 means there is no transaction and
-- a commit or rollback operation would generate an error.
-- Test whether the transaction is uncommittable.
IF (XACT_STATE()) = -1
BEGIN PRINT 'The transaction is in an uncommittable state.' + ' Rolling back transaction.'
ROLLBACK TRANSACTION;
END;
-- Test whether the transaction is active and valid.
IF (XACT_STATE()) = 1
BEGIN PRINT 'The transaction is committable.' + ' Committing transaction.'
COMMIT TRANSACTION;
END;
END CATCH;
GO

Sunday, March 15, 2009

AJAX is an acronym for Asynchronous JavaScript and XML. JavaScript is a scripting language that is supported by all of the major browsers. With AJAX, an application running in the browser can use JavaScript to send an XML message to the server, the server works on the request and sends an XML response back to the browser client, and the browser uses JavaScrip to process the response.
The AJAX Page Life Cycle
pageLoad Called after page is loaded from the Web server
pageUnload Called when page redirects, posts back, or makes an asynchronous call to the server
The UpdatePanel Control
The UpdatePanel enables partial-page updates, which is one of the most compelling reasons to use AJAX. It is responsible for eliminating the page flicker and scrolling back to the top of the page after postback—experience that people have become accustomed to but are still uncomfortable with all the same.
The UpdateProgress Control
Sometimes a partial-page postback takes longer than normal. Instead of making the user sit there wondering what is happening, it would be better to give the user some type of status. The UpdateProgress control helps in this area by letting the user know that progress is being made.



Saturday, March 14, 2009

Silverlight

Silverlight is a combination of different technologies, working harmoniously together to make it easier to build RIAs. Essentially, you can take parts of what you know about Extensible Application Markup Language (XAML), Windows Presentation Foundation (WPF), ASP.NET,
JavaScript, and AJAX combined with a lightweight runtime to create incredible browser experiences that were once only the domain of Flash.

Friday, February 20, 2009

Workflow architecture

The workflow functionality in Windows SharePoint Services 3.0 is built on the Windows Workflow Foundation (WF), a Microsoft Windows platform component that provides a programming infrastructure and tools for development and execution of workflow-based applications. WF simplifies the process of asynchronous programming to create stateful, long-running, and persistent workflow applications. The WF run-time engine manages workflow execution and allows workflows to remain active for long periods of time and to survive restarting the computer. Run-time services offer functionality such as transactions and persistence to manage errors gracefully and correctly.

The WF run-time engine provides the services that every workflow application needs, such as sequencing, state management, tracking capabilities, and transaction support. The WF run-time engine serves as a state machine responsible for loading and unloading workflows, as well as managing the current state of any workflows that are running. WF allows any application process or service container to run workflows by hosting WF — that is, loading WF within its process.

Windows SharePoint Services hosts the WF run-time engine. In place of the pluggable services that are included with WF, Windows SharePoint Services provides custom implementations of the following services for the engine: transaction, persistence, notifications, roles, tracking, and messaging. Developers can then create workflow solutions that run within Windows SharePoint Services.

Tuesday, February 17, 2009

Types of Workflows

Types of Workflows

Windows Workflow Foundation supports two fundamental workflow styles:
Sequential workflows Represents a workflow as a procession of steps that execute in order until the last activity completes. However, sequential workflows are not purely sequential in their execution. Because they can receive external events and include parallel logic flows, the exact order of activity execution can vary.
State machine workflows Represents a set of states, transitions, and actions. One state is denoted as the start state, and then, based on an event, a transition can be made to another state. The state machine can have a final state that determines the end of the workflow.
You can create workflows of either type for Windows SharePoint Services and SharePoint Server.
Sequential Workflows
Sequential workflows can best be represented graphically as a flowchart of actions, with a beginning, an end, and a sequential flow direction from start to finish. Sequential workflows can incorporate flow structures such as repetition, looping, and parallel branches, but ultimately progress from the initial action to the final action.
For example, suppose you were to chart the simple workflow that routes a document in Windows SharePoint Services for approval. When the workflow starts, the system notifies the specified reviewer, by e-mail message, that he or she has a document to review. The reviewer then reviews the document and notifies the system that the task is completed and whether the reviewer approves or rejects the document. Based on the reviewer response, the workflow executes one of two parallel branches. If the reviewer approved the document, the system moves the approved document to a specific SharePoint document library and then sends an e-mail message to the entire team notifying them of the approved document. If the reviewer rejects the document, the system notifies the document author.


State machine workflows
Unlike sequential workflows, state machine workflows do not have a prescribed execution flow, and need not have an end. Instead, state machine workflows define any number of states which an item may inhabit, and the events that transition the item from one state to another.
For Example, The workflow is initiated when a document is created, and ends when the document state is set as completed. In between, however, the document does not travel in a predetermined path, but instead transitions from state to state as events occur.
The state machine workflow is composed of state activities. Each state activity represents a state for the item. Each state activity can contain optional state initialization, state finalization, and one or more event handlers. Each event handler activity can handle one event. In response to the event handled, some processing can be done, and a transition can be made to another state.

Sunday, February 15, 2009

What are work flows?


Workflow is sometimes described as a series of tasks that produce an outcome. In the context of Microsoft SharePoint Products and Technologies, workflow is defined more narrowly as the automated movement of documents or items through a specific sequence of actions or tasks that are related to a business process. Workflows can be used to consistently manage common business processes within an organization by enabling organizations to attach business logic to documents or items in a SharePoint list or library. Business logic is basically a set of instructions that specifies and controls actions that happen to a document or item.

Sunday, January 25, 2009

Common (and simple) coding tasks in sharepoint

Well, everyone went to teched last week and I was left at work stuck with a project with a strict deadline. So out of boredom I decided that I will compile a small snippet database for beggining sharepoint developers.I see a lot of people in the microsoft public sharepoint developer forums asking these questions over and over again, so I thought I will save everyone some time by answering these right here.Some people may say these are RTFM questions, since the SDK contains all of these examples, but apperantly people dont bother with the SDK, or find it confusing to navigate through. So here is my 2 cents.
The purpose here is to give some code samples to common tasks like:
getting a reference to a site
Iterating over all lists in a site
getting a reference to a list
getting a reference to an item in a list
getting a reference to the item's properties
getting a reference to a document and its properties
adding a new item to a list
modifying an item in a list
If you feel I should add to this list, let me know and I will write some sample code. However, please remember this is for simple, common tasks and I wont start giving application samples here.
So, lets get down to it!
Getting a reference to a site
Ok, you have a sharepoint site in a URL "http://server/sites/site" and you want to get the object of the site from its URL. What do you do?using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
}
}
Now you have the SPWeb object, allowing you to get information about the site you used in the URL. For example, iterating all lists in the site:using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
string linksHtml = "";
foreach(SPList list in myWeb.Lists)
{
string listLink = "" + list.Title + "("+list.Items.Count+")
";
linksHtml += listLink;
}
}
}
The above example also showed how to get a reference to a list by iterating over the lists in a site. But what if you want a specific list called "contacts"? The following will show you how to get the object for a list that you know the name of:using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList contactsList = myWeb.Lists["Contacts"];
}
}
Now lets iterate through the items in the list and get item's properties:using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList contactsList = myWeb.Lists["Contacts"];
foreach (SPListItem contact in contactsList.Items)
{
string contactLastName = contact["Last Name"].ToString();
}
}
}
Now some of you are saying - "what about documents?", to which I answer that document libraries are the same as lists (ok, there are some differences but we will leave that for future articles). To get to a document in a document library you can either use the code above to iterate through the library and its files, or, if you know the file's URL, you can do this:
using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPFile file = myWeb.GetFile("http://server/sites/site/library/folder/file");
}
}
File properties are available through its Item property. If you have for example a text field in the document library called "My Custom String Property", and you want to know the value for that field in a specific file, use the following code:using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPFile file = myWeb.GetFile("http://server/sites/site/library/folder/file");
string filePropertyValue = file.Item["My Custom String Property"].ToString();
}
}
We now want to add a new item to a list:
using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList contactsList = myWeb.Lists["Contacts"];
SPListItem newItem = contactsList.Items.Add();
newItem["First Name"] = "Ishai";
newItem["Last Name"] = "Sagi";
newItem.Update();
}
}
Lets change all items in the list to build the email address based on the first and last name (in the format of 'first.last@testing.com') :
using(SPSite mySite = new SPSite("http://server/sites/site"))
{
using(SPWeb myWeb = mySite.OpenWeb())
{
SPList contactsList = myWeb.Lists["Contacts"];
foreach(SPListItem existingItem in contactsList.Items)
{
existingItem["E-mail Address"] = existingItem["First Name"] + "." + existingItem["Last Name"] + "@testing.com";
newItem.Update();
}
}
}

Tuesday, January 20, 2009

Whats new in C# 4.0?


Whats new in C# 4.0?
Every new version of C# has a major improvement theme. 1.0 was about managed code; 2.0 was about generics; 3.0 introduced Functional Programming and LINQ.
And now 4.0 introduces dynamic programming.
A new keyword called dynamic which can be used to define a variable, function reurn type or a parameter, which the compiler will not bother to resolve calls during compilation, instead it will delay all method resolution to run time.

This technology dynamic lookup. The basis of the dynamic resolution is the IDynamicObject interface, shared with the Dynamic Language Runtime. This has on it methods like Invoke which the compiler will call to allow the object itself to participate in method resolution.


There are three primary scenarios that will be enabled by the new support for dynamic lookup:

Office automation and other COM Interop scenarios

Consuming types written in dynamic languages

Enhanced support for reflection .

Sunday, January 18, 2009

Generics
Generics are a new feature in version 2.0 of the C# language and the common language runtime (CLR). Generics introduce to the .NET Framework the concept of type parameters, which make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations.


Generics Overview
Use generic types to maximize code reuse, type safety, and performance.
The most common use of generics is to create collection classes.
The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace. These should be used whenever possible in place of classes such as ArrayList in the System.Collections namespace.
You can create your own generic interfaces, classes, methods, events and delegates.
Generic classes may be constrained to enable access to methods on particular data types.
Information on the types used in a generic data type may be obtained at run-time by means of reflection.

Sunday, January 4, 2009

Iterators in 3.5

Iterators
Iterators are a new feature in C# 2.0. An iterator is a method, get accessor or operator that enables you to support foreach iteration in a class or struct without having to implement the entire IEnumerable interface. Instead, you provide just an iterator, which simply traverses the data structures in your class. When the compiler detects your iterator, it will automatically generate the Current, MoveNext and Dispose methods of the IEnumerable or IEnumerable interface.
Iterators Overview
An iterator is a section of code that returns an ordered sequence of values of the same type.
An iterator can be used as the body of a method, an operator, or a get accessor.
The iterator code uses the yield return statement to return each element in turn. yield break ends the iteration. For more information, see
yield.
Multiple iterators can be implemented on a class. Each iterator must have a unique name just like any class member, and can be invoked by client code in a foreach statement as follows: foreach(int x in SampleClass.Iterator2){}
The return type of an iterator must be IEnumerable,
IEnumerator, IEnumerable, or IEnumerator.
The
yield keyword is used to specify the value, or values, returned. When the yield return statement is reached, the current location is stored. Execution is restarted from this location the next time the iterator is called.

Tuesday, September 30, 2008

Visual Studio 2010

Visual Studio 2010 and .NET Framework 4.0 Overview
Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from Microsoft. Designed to address the latest needs of developers, Visual Studio and the .NET Framework deliver key innovations in the following pillars:
Democratizing Application Lifecycle ManagementApplication Lifecycle Management (ALM) crosses many roles within an organization and traditionally not every one of the roles has been an equal player in the process. Visual Studio Team System 2010 continues to build the platform for functional equality and shared commitment across an organization’s ALM process.
Enabling emerging trendsEvery year the industry develops new technologies and new trends. With Visual Studio 2010, Microsoft delivers tooling and framework support for the latest innovations in application architecture, development and deployment.
Inspiring developer delightEver since the first release of Visual Studio, Microsoft has set the bar for developer productivity and flexibility. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving upon it for roles involved with the software development process.
Riding the next generation platform waveMicrosoft continues to invest in the market leading operating system, productivity application and server platforms to deliver increased customer value in these offerings. With Visual Studio 2010 customers will have the tooling support needed to create amazing solutions around these technologies.
Breakthrough Departmental ApplicationsCustomers continue to build applications that span from department to the enterprise. Visual Studio 2010 will ensure development is supported across this wide spectrum of applications.
Over the next few months we will provide more detail in each of these pillars. We will start with “Democratizing Application Lifecycle Management.”
Please check back shortly to see the next pillar, “Enabling emerging trends.”

Microsoft Visual Studio Team System 2010 – Democratizing Application Lifecycle ManagementVisual Studio Team System 2010 will deliver new capabilities that embrace the needs of the users in the lifecycle – from architects to developers, from project managers to testers.
Among the great new functionality in VSTS 2010:
Discover and identify existing code assets and architecture with the new Architecture Explorer.
Design and share multiple diagram types, including use case, activity and sequence diagrams.
Improve testing efforts with tooling for better documentation of test scenarios and more thorough collection of test data.
Identify and run only the tests impacted by a code change easily with the new Test Impact View.
Enhanced version control capabilities including gated check-in, branch visualization and build workflow.
Key to a shared understanding of the application is the use of modeling tools. Modeling has traditionally been done by professional architects and system designers. Our approach is to enable both technical and non-technical users to create and use models to collaborate and to define business and system functionality graphically.


To learn more about the new features and capabilities in Visual Studio Team System 2010 follow the links below.
Modeling that Works with CodePowerful modeling tools are important for both defining new systems as well as discovering architectural information about existing systems. Our new modeling tools have tight integration into the actual code of the application enabling a developer or architect to use models to enforce constraints on code, as well as to explore existing code assets.
Eliminating “No-Repro”One of the most difficult problems has always been that of the bug that can’t be reproduced – the “no repro” bug. There are a lot of factors that drive these types of bugs and we have worked to create tools to isolate the issue and enable faster fixes.
Identify the Test ImpactAfter making a change to the code it is critical to test the changes to prove they work as expected and to ensure no unexpected downstream effect. Test Impact Analysis helps developers quickly check-in code with confidence by running only the necessary tests.


My New Blog

Hi All,

Welcome to my new blog.



Sanjiv