Tuesday, May 27, 2008

Caching in ASP.NET

Abstract Caching can dramatically improve the performance of your application by storing the page output or application data across HTTP requests. In this article, Joydip discusses the different types of Caching in ASP.NET with lucid code examples.

Caching is a feature of ASP.NET that improves the performance of web applications by minimizing the usage of server resources to a great extent. This article discusses Caching, its types and contains some lucid code examples to illustrate On- Demand Data Caching.

What is Caching?

Caching is a feature that stores data in local memory, allowing incoming requests to be served from memory directly.

Benefits of Caching

The following are the benefits of using Caching

  • Faster page rendering
  • Minimization of database hits
  • Minimization of the consumption of server resources

Types of Caching

Caching in ASP.NET can be of the following types
  • Page Output Caching
  • Page Fragment Caching
  • Data Caching
  • Page Output Caching

This is a concept by virtue of which the output of pages is cached using an Output Cache engine and all subsequent requests are served from the cache. Whenever a new request comes, this engine would check if there is a corresponding cache entry for this page. If there is a cache hit, i.e., if the engine finds a corresponding cache entry for this page, the page is rendered from the cache, else, the page being requested is rendered dynamically.

This is particularly useful for pages that are static and thus do not change for a considerable period of time.

Page output caching can be implemented in either of the following two ways:

  • At design time using the OutputCache directive
  • At runtime using the HttpPolicy class

The following is the complete syntax of page output caching directive

<%@ OutputCache Duration="no of seconds"
Location="Any | Client | Downstream | Server | None"
VaryByControl="control"
VaryByCustom="browser |customstring"
VaryByHeader="headers"
VaryByParam="parameter" %>

The following statement is used to implement output caching in an aspx page at design time. The directive is placed at the top of the .aspx page.

<%@OutputCache Duration="30"
VaryByParam="none" %>

The duration parameter specifies for how long the page would be in cache and the VaryByParam parameter is used to cache different views of the page. In the code example above, the cache duration is 30 seconds. Cache duration is a required field, and must be set to an integer greater than zero. The VaryByParam parameter, which is also required, specifies whether the cached page would differ in versions based on any parameter. A value of * in the same parameter indicates that the page would be cached based on all the Get/Post parameters. We can also specify one or more Get/Post parameter(s). Hence, the same statement shown above can have the following variations. The VaryByParam parameter is particularly useful in situations where we require caching a page based on certain criteria. As an example, we might require to cache a specific page based on the EmployeeID.

<%@OutputCache Duration="30"
VaryByParam="*" Location = "Any"%>  

<%@OutputCache Duration="30"
VaryByParam="EmployeeID" Location = "Client" %>  
<%@OutputCache Duration="30"
VaryByParam="EmployeeID;Basic" %> 

The VaryByParam parameter can also have multiple parameters as shown in the example above.

The location parameter is used to specify the cache location, either the server of the client.

To set a page's cacheability programmatically we have to use the method Response.Cache.SetCacheability. This method accepts the following parameters

  • NoCache
  • Private
  • Public
  • Server

The code snippet below shows how to set a page’s cacheability programmatically:

Response.Cache.SetCacheability(HttpCacheability.Server);

Additionally we can set other properties which map to the same fields available when using the OutputCache directive on the page:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(30));
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByParams["EmployeeID"]= true; 

Page Fragment Caching

This allows specific portions of the page to be cached rather than caching the whole page. This is useful in situations where we can have a page that contains both static and dynamic content. The following code depicts how this can be accomplished.

<%@ OutputCache Duration="15"
VaryByControl="EmpID;DeptID" VaryByParam="*"%>   

This directive is placed at the top of any User Control (.axcx file).

Data Caching

The following code is an implementation of On-Demand caching. The method GetUserInfo checks to see if the data exists in the cache. If it is present, it is returned from the cache, else, the GetUserInfoFromDatabase method fills the DataSet from the database and then populates the Cache.

public DataSet GetUserInfo()
{  

  string cacheKey = "UserInfo";  
  DataSet ds = Cache[cacheKey] as DataSet;  
  if (ds == null)  

 {    
   ds = GetUserInfoFromDatabase();    
   Cache.Insert(cacheKey, ds, null, NoAbsoluteExpiration,      
   TimeSpan.FromHours(15),CacheItemPriority.High, null);  

}     
return ds;
}  

DataSet GetUserInfoFromDatabase() {
// Usual code to populate a data set from thedatabase. This data set 

// object is then returned. 
}

Cache Expirations

Cache expirations can be of the following types

  • Time Based Expiration
  • Dependency Based Expiration
  • Time Based Expiration

This is used to specify a specific period of time for which the page would remain in the cache. The following statement specifies such expiration for a page in the code behind of a file using C#.

Response.Cache.SetExpires(DateTime.Now.AddSeconds(120));
This can also be accomplished by stating the same in the output cache directive as shown here.
<%@OutputCache Duration="60"
VaryByParam="None" %>

Cache Expiration

Cache expiration strategies can be implemented in either of the following two ways:
  • Time Based
  • File Based
  • Key Based
Time Based Expiration

This is implemented by specifying a specific duration for which the item would remain in the cache. When the time elapses, the item is removed from the cache and subsequent requests to retrieve the item returns a null. Time based expiration strategies can be of the following two types:

  • Absolute
  • Sliding
  • Absolute
Cache.Insert("UserInfo", dsUserInfo, null,
DateTime.Now.AddMinutes(1), NoSlidingExpiration); 

Sliding

Cache.Insert("UserInfo", dsUserInfo, null,
NoAbsoluteExpiration,

TimeSpan.FromSeconds(60));

Note that you cannot use both Absolute and Sliding expirations at the same time.

File Based Expiration

This is implemented by using a file as a dependency. Whenever the contents of the dependency file are changed, the cached is invalidated. Please refer to the code below.
CacheDependency cacheDependency = newCacheDependency("userinfo.xml");
Cache.Insert("UserInfo", xmldocObject,cacheDependency); 
In addition to files, entire folders can be monitored for changes using the CacheDependency class.

Key Based Expiration

The third type of dependency is the key dependency. With it, a cache entry can be made to depend on another, existing dependency. When the depended-upon entry changes or expires, the dependent entry will also be expired. An array of keys can be specified as a single CacheDependency.
string[] keys = new string[] {"key"};
CacheDependency cacheDependency = newCacheDependency(null,keys);
Cache.Insert("UserInfo", xmldocObject,cacheDependency);

Using Callbacks

The delegate CacheItemRemovedCallback event handler is used to respond to the event that is raised when an item is deleted from cache. This handler contains the code to populate / re-populate the cache. Please refer to the code snippet below.
public void onRemoveCallBack(string str, objectobj, CacheItemRemovedReason reason)
{  
   DataSet dataset = GetUserInfoFromDatabase();  

   Cache["userInfo"] = dataset;
} 

1. First declare a class variable onRemove as shown below.

private static CacheItemRemovedCallback onRemove = null; 

2. This delegate is invoked as shown below.

onRemove = newCacheItemRemovedCallback(this.onRemoveCallBack);

3. The following code snippet shows how this handler is specified when items are added to the Cache.


Cache.Insert("userInfo", ds, null, DateTime.Now.AddMinutes(2),
NoSlidingExpiration, CacheItemPriority.High,
CacheItemPriorityDecay.Slow, onRemove);

The Cache Class

The Add/Insert method of the Cache class is used to add/insert an item into the cache. The Remove method removes a specified item from the cache. The Cache class contains the following properties and methods.

Properties

  • Count
  • Item

Methods

  • Add
  • Equals
  • Get
  • GetEnumerator
  • GetHashCode
  • GetType
  • Insert
  • Remove (Overloaded)
  • ToString
Conclusion Judicious use of the right type of caching can dramatically improve the performance of web applications. For more information about caching, please visit the ASPAlliance Caching

Microsoft .NET Terminologies at a Glance

Abstract This article defines many important terminologies that are related to Microsoft .NET so as to enable the reader to have a ready guide to the technical terms. Terminologies related to Microsoft .NET Framework, ASP.NET, ADO.NET, XML, Biztalk Server, etc. are covered. This will also help readers prepare themselves to go into interviews confidently. Overview [ Back To Top ] My objective in designing this article is to put an end to the arduous struggle of an IT professional seeking an understandable resource for the core terminologies of Microsoft.NET. Let me save you valuable time and energy by providing you with an article that gives you many of the important terminologies in Microsoft .NET and its related technologies. This article discusses most of the important terminologies related to Microsoft .NET Framework, ASP.NET, ADO.NET, Remoting and Web Services. The terminologies are not organized in an alphabetical order, rather they are organized in the order of the categories that they belong to. The Common Language Specification This is a subset of the Common Type System (CTS) and defines a set of conventions that are targeted at language interoperability of all the languages that run within the .NET environment. The Common Type System The Common Type System (CTS) is a standard that defines the necessary rules for type interoperability for the languages targeting the .NET environment. The common type system supports the following types. · Value Types · Reference Types .NET Framework Class Library The .NET Framework Class Library (FCL) is a set of managed classes that are responsible for providing access to the system services in the managed environment of Microsoft.NET. The Common Language Runtime The CLR is a runtime execution engine of .NET that provides an environment to execute programs that are targeted at the .NET platform. It provides memory allocation, security, code verification, type verification, exception handling and garbage collection in the managed environment. Common Language Infrastructure The Common Language Infrastructure or the CLI provides support for language interoperability in the .NET managed environment. It is comprised of the following features. · A File Format (PE) · Metadata · MSIL · Base Class Library Assembly An assembly is a group of resources and types, along with the metadata about those resources and types, deployed as a single unit. Just In Time Compiler The Just In Time Compiler or the JIT is responsible for compiling units of code and caching them at runtime as and when they are needed. Since the compilation occurs at runtime, it is known as a Just In Time Compilation. MSIL A program compiled in the .NET managed environment generates an intermediate code to support platform independence. This is called the MSIL or Microsoft Intermediate Language. Strong Name A Strong Name is a unique identifier given to an assembly using cryptography and a digital signature that is used to identify a particular assembly. An assembly is provided a strong name using the utility called sn.exe. A strong name consists of the following. · Name of the Assembly · Digital Signature · Version Number · Culture Information Global Assembly Cache The Global Assembly Cache is a system wide storage of shared assemblies. Assemblies can be stored or moved to and from the Global Assembly Cache using a tool called GacUtil. Managed Code A managed code is one that provides restricted access to the system’s resources and can be executed only in a managed environment that is provided in Microsoft .NET by the Common Language Runtime. Un-Managed Code An Un-Managed code is one that executes outside of the Common Language Runtime environment and can perform unsafe operations. Managed Data Managed Data refers to the objects that are created by the Common Language Runtime environment and can be garbage collected implicitly by the Garbage Collector. Shared Assembly A Shared Assembly is one that can be referred by more that one application. All shared assemblies should contain a strong name and should be located in the Global Assembly Cache (GAC). Private Assembly A Private Assembly is one that is private to one application. In other words, it can be accessed by the containing application only. Satellite Assembly When you wish to localize the application, it can be written in culture-neutral code and can distribute the localized modules in separate assemblies called satellite assemblies. Assembly Manifest The Assembly Manifest contains the information about an assembly. This includes the version number of the assembly, the list of the files that comprise the assembly, etc. An assembly manifest is contained in the dll file or the exe file itself. Resource A resource refers to an addressable unit of data that is available for use by an application. It consists of one or more of the following. · Texts · Files · Documents · Images · The .NET tool called resgen.exe is used to create resource files from the resource information that is stored in text or XML files. Localization Localization is the practice of designing and developing software that will properly use all of the conventions defined for a specific locale. An assembly that is used to provide localization feature in ASP.NET applications is referred to as a Satellite Assembly. Native Image Generator This is a .NET tool that is used to compile a managed assembly to the native code and then store that in the local assembly cache. The name of this tool is Ngen.exe. Value Type A value type is one that contains the value rather than the reference and is stored in the stack memory. Examples of value types are integers, floats, doubles, structures, etc. Reference Type A reference type contains a reference to the actual object in memory and is stored in the managed heap. Objects of classes are good examples of reference types. Boxing Boxing refers to the conversion of a value type to a reference type. Value types are stored in the stack and reference types are stored in the managed heap. Un-Boxing This refers to the conversion of a reference type to a value type. Garbage Collection Garbage Collection is a technique introduced in Microsoft .NET that manages memory cleanup implicitly. This implicit reclaiming of memory in the .NET managed environment is handled by the Common Language Runtime. Dispose Method The Dispose method can be used in an unsealed class to cleanup resources explicitly. It should be noted that both the Dispose and the Finalize methods should make a call to their parents' respective methods after they have disposed or finalized their own members. A class that needs to have this method implemented should implement the IDisposable interface. Finalize Method The finalize method is a protected member of the Object class and is implicitly called at the runtime to cleanup unmanaged resources before the object is destroyed. Code Verification This is a feature that enforces type safety or type security by checking the code prior to its execution in the run time environment. Therefore, it does not allow malicious code to get executed in the managed environment. Authentication and Authorization This is a security measure that is used to specify the user’s identity and authorization in ASP.NET. The process of authorization determines whether an authenticated user has access to a specific resource. Authentication and Authorization details of an ASP.NET application are specified in the web.config file. There can be three types of authentication in ASP.NET. · Forms Authentication · Windows Authentication · Passport Authentication Web.Config File The web.config file is the configuration file for an ASP.NET web application. Typically, the following information is stored in a web.config file. · Database Connection Strings · Security · Session States · Impersonation · Error handling Machine.Config File The machine.config file contains the configuration settings for the entire application and is located in the Config sub-folder of the Microsoft .NET installation directory. ASP.NET ASP.NET is a language neutral, interoperable, server-side technology that allows creation, execution and deployment of scalable Web Applications and Services. Caching Caching is a feature that stores the data in the memory for serving the incoming requests from the memory itself. Caching in ASP.NET can be of three types. · Page Output Caching · Page Fragment Caching · Data Caching Singleton Pattern A singleton pattern states that we can have a singleton class that can be instantiated only once in the application domain and provides a global point of access to it. Application Domain An application domain refers to the logical and physical boundary created around every .NET application. An application domain is created by the Common Language Runtime and supports execution of multiple .NET applications in the same process by isolating them in different application domains. View State This is a client-side state management technique that continues the state of server controls by maintaining the state of pages across postbacks. The view state is an encoded hashed string and is stored in a hidden field called __VIEWSTATE. Session State A session is the period of a connection between a server and a client. The Session State allows storage of objects in a user’s session. A session can be stored in one of the following ways. · InProc · State Server · SQL Server Application State This is a state management technique that allows objects to be stored and then globally accessed or shared by multiple modules of the application. In ASP.NET, application state is maintained by the class HttpApplicationState. Interface Definition Language (IDL) The Interface definition Language (IDL) defines a protocol between the server and the client so that they can communicate in heterogeneous environments. Universal Description, Discovery and Integration (UDDI) Universal Description, Discovery and Integration is a platform independent, XML based, distributed directory that allows the enterprises to list themselves over the internet. The UDDI business registration contains the following features. · Green Pages · White Pages · Yellow Pages Web Service Description Language (WSDL) The Web Service Description Language (WSDL) defines XML based contract services for describing the network services as a collection of communication end points. A WSDL document contains the following. · Messages · Operation · Types · Service · Port and its type Simple Object Oriented Protocol (SOAP) This is an XML-based protocol that is used to exchange structured data and type information in a distributed environment. Web Services A web service is SOAP based, platform–independent software component that exposes itself through open communication channels of the web applications running on potentially different platforms. Remoting Remoting allows two processes, a Server and a Client, to inter-communicate in the same system, the same network or across networks. In Remoting, a server and client communicate using a Channel. Service Oriented Architecture Service Oriented Architecture is an architecture that provides a seamless Enterprise Information Integration between loosely coupled distributed applications or services over the network. Service A service is an implementation of a well-defined, self-contained, independent business functionality that accepts one or more requests and returns one or more responses through a well-defined, standard interface. Smart Client Architecture The Smart Client Architecture is a deployable, multi-platform architecture that allows local application to connect to a server based application using web services. It provides an adaptive and rich user interactive experience by using local resources. A Smart Client application can work in both connected and disconnected modes. ADO.NET ADO.NET is an object oriented data access technology that enables you to access data from a managed environment. It is essentially a collection of some classes used to communicate between an application and a database. Connection Pool A Connection Pool is a pool of available or ready-to-use connections. When a new connection is requested it is served from the connection pool if one exists. If not, a new connection is created. Connection Pooling improves the performance of applications to a large extent. DataProvider A DataProvider encapsulates the protocols that ADO.NET uses to interact with different types of databases. DataSet The DataSet is an in–memory, disconnected, XML compliant representation of the data. Data in a DataSet can be changed, unlike a DataReader which is read only. DataReader A DataReader is a connected, forward only, read only stream of data that is retrieved from the database. DataAdapter The DataAdapter is a bridge between the DataSet and the underlying database. It provides a set of methods and properties to move data between a database and its in-memory representation, the DataSet. DataView A DataView is a class that provides a customized view of the DataSet. It is typically used to sort or filter the rows. Command The Command object is used to send the SQL Statements to the database. Commands are used to insert data, retrieve data and execute stored procedures in the database. Connection The Connection object establishes a connection to the database using the user name, password and the database name as parameters. Transactions A transaction is a block of statements that guarantees that all or none of the statements in the block are executed. In ADO.NET, a transaction can be started by using the BeginTransaction() method on the currently active Connection. To commit the transaction, the method CommitTransaction() is used. In order to abandon the transaction, the method Rollback() is executed. Serialization This refers to the storage of an object into a persistent storage medium in a stream of bytes. The opposite is de-serialization and is used to retrieve a serialized object from a storage medium. Reflection This is a feature that allows us to inspect the metadata of an assembly at runtime. Reflection can be used to retrieve metadata information, such as the following. · Classes · Methods · Properties · Events Biztalk Server This is a set of Microsoft Server Applications that allow integration, automation and management of different server applications. Exchange Server This is a set of Microsoft Server Applications that are responsible for integrating messaging and data storage technologies. Commerce Server This is Microsoft’s Business Server that is used for managing and developing business web sites. Array An array is a collection of homogenous objects. It is a group of elements of the same type that share a common name. The size of an array is fixed and cannot be changed at runtime. ArrayList An ArrayList is a collection of heterogeneous elements- elements of different types. Unlike an array, its size can be changed dynamically. HashTable A HashTable is a collection of heterogeneous objects that can be referred using either an index or a key. Elements of an ArrayList can be referred to using an index only. COM+ COM+ or COM Plus is a distributed, transactional, component-based technology that can be used in a multi-tiered architecture and provides support for Object Pooling. Delegate A delegate is a managed function pointer that refers to a method. A multi-cast delegate is one that points to and can eventually fire off different methods. A delegate is used to implement event handling in Microsoft .NET. Event Handler An event handler is a method that is executed in response to an event. Exception An exception is an event that is generated as a result of a runtime error. An exception is handled using the exception blocks. An exception that cannot be handled is referred to as a fatal exception and causes the flow of execution of the current program to terminate unexpectedly. Try/Catch Block A try/catch block is used in exception handling and provides a mechanism to trap runtime errors that can occur on execution of the application. A try block contains the code that can generate a runtime error. The catch block contains statements that are executed once the appropriate exception has occurred. A try block can contain one or more catch blocks or a finally block. Finally Block A finally block is one that is executed irrespective of whether an exception occurs or not. Typically, it is used in Exception Handling mechanism to release resources. Namespace A namespace refers to a logical grouping of types or identifiers used in a program.

22 New Features of Visual Studio 2008 for .NET Professionals

1. LINQ Support

LINQ essentially is the composition of many standard query operators that allow you to work with data in a more intuitive way regardless.

LINQ

The benefits of using LINQ are significant – Compile time checking C# language queries, and the ability to debug step by step through queries.

2. Expression Blend Support

Expression blend is XAML generator tool for silverlight applications. You can install Expression blend as an embedded plug-in to Visual Studio 2008. By this you can get extensive web designer and JavaScript tool.

3. Windows Presentation Foundation

WPF provides you an extensive graphic functionality you never seen these before. Visual Studio 2008 contains plenty of WPF Windows Presentation Foundation Library templates. By this a visual developer who is new to .NET, C# and VB.NET can easily develop the 2D and 3D graphic applications.

Visual Studio 2008 provides free game development library kits for games developers. currently this game development kits are available for C++ and also 2D/3D Dark Matter one image and sounds sets.

4. VS 2008 Multi-Targeting Support

Earlier you were not able to working with .NET 1.1 applications directly in visual studio 2005. Now in Visual studio 2008 you are able to create, run, debug the .NET 2.0, .NET 3.0 and .NET 3.5 applications. You can also deploy .NET 2.0 applications in the machines which contains only .NET 2.0 not .NET 3.x.

5. AJAX support for ASP.NET

AJAX

Previously developer has to install AJAX control library separately that does not come from VS, but now if you install Visual Studio 2008, you can built-in AJAX control library. This Ajax Library contains plenty of rich AJAX controls like Menu, TreeView, webparts and also these components support JSON and VS 2008 contains in built ASP.NET AJAX Control Extenders.

6. JavaScript Debugging Support

Since starting of web development all the developers got frustration with solving javascript errors. Debugging the error in javascript is very difficult. Now Visual Studio 2008 makes it is simpler with javascript debugging. You can set break points and run the javaScript step by step and you can watch the local variables when you were debugging the javascript and solution explorer provides javascript document navigation support.

7. Nested Master Page Support

Already Visual Studio 2005 supports nested master pages concept with .NET 2.0, but the problem with this Visual Studio 2005 that pages based on nested masters can't be edited using WYSIWYG web designer. But now in VS 2008 you can even edit the nested master pages.

8. LINQ Intellisense and Javascript Intellisense support for silverlight applications

javascriptintellisense

Most happy part for .NET developers is Visual Studio 2008 contains intellisense support for javascript. Javascript Intellisense makes developers life easy when writing client side validation, AJAX applications and also when writing Silverlight applications

Intellisense Support: When we are writing the LINQ Query VS provides LINQ query syntax as tool tips.

9. Organize Imports or Usings: We have Organize Imports feature already in Eclipse. SInce many days I have been waiting for this feature even in VS. Now VS contains Organize Imports feature which removes unnecessary namespaces which you have imported. You can select all the namespaces and right click on it, then you can get context menu with Organize imports options like "Remove Unused Usings", "Sort Usings", "Remove and Sort". Refactoring support for new .NET 3.x features like Anonymous types, Extension Methods, Lambda Expressions.

10. Intellisense Filtering: Earlier in VS 2005 when we were typing with intellisense box all the items were being displayed. For example If we type the letter 'K' then intellisense takes you to the items starts with 'K' but also all other items will be presented in intellisense box. Now in VS 2008 if you press 'K' only the items starts with 'K' will be filtered and displayed.

11. Intellisense Box display position

javascriptintellisense

Earlier in some cases when you were typing the an object name and pressing . (period) then intellisense was being displayed in the position of the object which you have typed. Here the code which we type will go back to the dropdown, in this case sometimes programmer may disturb to what he was typing. Now in VS 2008 If you hold the Ctrl key while the intellisense is dropping down then intellisense box will become semi-transparent mode.

12. Visual Studio 2008 Split View

spit

VS 205 has a feature show both design and source code in single window. but both the windows tiles horizontally. In VS 2008 we can configure this split view feature to vertically, this allows developers to use maximum screen on laptops and wide-screen monitors.

Here one of the good feature is if you select any HTML or ASP markup text in source window automatically corresponding item will be selected in design window.

13. HTML JavaScript warnings, not as errors: VS 2005 mixes HTML errors and C# and VB.NET errors and shows in one window. Now VS 2008 separates this and shows javascript and HTML errors as warnings. But this is configurable feature.

14. Debugging .NET Framework Library Source Code:

Now in VS 2008 you can debug the source code of .NET Framework Library methods. Lets say If you want to debug the DataBind() method of DataGrid control you can place a debugging point over there and continue with debug the source code of DataBind() method.

15. In built Silverlight Library

silverlight

Earlier we used to install silverlight SDK separately, Now in VS 2008 it is inbuilt, with this you can create, debug and deploy the silverlight applications.

16. Visual Studio LINQ Designer

LINQ

Already you know in VS 2005 we have inbuilt SQL Server IDE feature. by this you no need to use any other tools like SQL Server Query Analyzer and SQL Server Enterprise Manger. You have directly database explorer by this you can create connections to your database and you can view the tables and stored procedures in VS IDE itself. But now in VS 2008 it has View Designer window capability with LINQ-to-SQL.

17. Inbuilt C++ SDK

Earlier It was so difficult to download and configure the C++ SDK Libraries and tools for developing windows based applications. Now it is inbuilt with VS 2008 and configurable

18. Multilingual User Interface Architecture - MUI

MUI

MUI is an architecture contains packages from Microsoft Windows and Microsoft Office libraries. This supports the user to change the text language display as he wish.

Visual Studio is now in English, Spanish, French, German, Italian, Chinese Simplified, Chinese Traditional, Japanese, and Korean. Over the next couple of months. Microsoft is reengineering the MUI which supports nine local languages then you can even view Visual studio in other 9 local languages.

19. Microsoft Popfly Support

popfly

Microsoft Popfly explorer is an add-on to VS 2008, by this directly you can deploy or hosting the Silverlight applications and Marshup objects

20. Free Tools and Resources

People may feel that I am a promoter to Visual Studio 2008 as a salesman, but we get plenty of free resources and free tools with Visual Studio 2008.

  • Visual Studio 2008 Trial
  • 101 LINQ Samples
  • Free .NET 3.5 control libraries with free sample programs,
  • You can get plenty of free video training tutorials from Microsoft BDLC - Beginner Developer Learning Center,
  • C++ games development library,
  • Microsoft has provided lot of e-Books,
  • P2P library and
  • Microsoft is providing Coding4Fun sample program kit.
  • Visual Studio Registration Discounts: If you register the Visual Studio you get Free Control Libraries, Books, Images, and Discounts.
  • Download Visual Studio 2008 free trial

    21. We can use for Commercial

    Earlier you were spending lot of money to host your .NET applications for commercial use. Now you no need to worry Now Microsoft is providing you to host your application free on Popfly for web pages and also visual studio express projects.

    If you like this article, Please share with others

    Other Interested .NET Readings:
    Writing/Developing Facebook Applications in .NET using Facebook.NET SDK
    Refactor .NET code using Visual Studio and Refactor! Pro
    Dead-end for Microsoft ?
    .NET Obfuscation using Dotfuscator for Source Code Protection
    Windows System Tray Programming using C# and VB.NET
    Microsoft Office 2007 Features and Free Download
  • Evaluation of .Net Framework

    Send EMAIL through ASP.NET

    //SmtpMail.SmtpServer = "127.0.0.1"; SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["SmtpServer"]; System.Web.Mail.MailMessage msgMail = new System.Web.Mail.MailMessage(); msgMail.From = txtFrom.Text.ToString(); msgMail.To = txtTo.Text; msgMail.Cc = txtC.Text; msgMail.Bcc = txtBcc.Text; msgMail.Subject = txtSubject.Text; msgMail.Body = txtMessage.Text; msgMail.Attachments.Add(new MailAttachment(txtAttachment.Text)); SmtpMail.Send(msgMail);

    Saturday, May 24, 2008

    Display confirmation when closing browser.

    Wednesday, May 14, 2008

    Sql Server Transactions - ADO.NET 2.0 - Commit and Rollback - Using Statement - IDisposable

    Here is the basic template for an ADO.NET 2.0 Transaction: using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = connection.CreateCommand(); SqlTransaction transaction = null; try { // BeginTransaction() Requires Open Connection connection.Open(); transaction = connection.BeginTransaction(); // Assign Transaction to Command command.Transaction = transaction; // Execute 1st Command command.CommandText = "Insert ..."; command.ExecuteNonQuery(); // Execute 2nd Command command.CommandText = "Update..."; command.ExecuteNonQuery(); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } A c# using statement wraps up the connection, because SqlConnection implements IDisposable. The using statement makes sure that Dispose() gets called on the connection object so it can free up any unmanaged resources. Before you can begin a transaction, you must first open the connection. You begin your transaction and then assign any newly created command objects to that transaction and perform queries as necessary. Commit the transaction. If an error occurs, Rollback the transaction in a catch statement to void out any changes and then rethrow the error so that the application can deal with it accordingly. The connection is properly closed in the finally statement, which gets called no matter what, and any unmanaged resources are disposed when the using statement calls Dispose() on the connection. Pretty simple solution to a fairly advanced topic. The above template could actually implement a second c# using statement around command, because SqlCommand also implements IDisposable. I don't know that it is really necessary, however. More theoretical than probably anything. I just like to see using statements around anything that implements IDisposable: using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = connection.CreateCommand()) { SqlTransaction transaction = null; try { // BeginTransaction() Requires Open Connection connection.Open(); transaction = connection.BeginTransaction(); // Assign Transaction to Command command.Transaction = transaction; // Execute 1st Command command.CommandText = "Insert ..."; command.ExecuteNonQuery(); // Execute 2nd Command command.CommandText = "Update..."; command.ExecuteNonQuery(); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } }