Sunday, April 11, 2010

Garbage Collection in C#

Introduction

All the garbage collection mechanisms have one thing in common, that is they take the responsibility of tracking memory usage.

Understanding Garbage Collection

The .NET garbage collector is optimized for the following assumptions

1. Objects that were recently allocated are most likely to be freed.
2. Objects that have lived the longest are least likely to be become free.
3. Objects allocated together are often used together.

The .NET garbage collector is known as generational garbage collector. The objects allocated are categorized into three generations. Most recently allocated objects are placed in generation 0.
Objects in generation 0, that survive a garbage collection pass are moved to generation 1.
generation 2 contains long-lived objects, that survive after the two collection passes.

A garbage collection pass for generation 0 is the most common type of collection. Generation 1 collection pass is performed if generation 0 collection pass is not sufficient to reclaim memory.
Atlast, generation 2 collection pass is peformed if collection pass on generation 0 and 1 are not sufficient to reclaim memory. If no memory is available, after all the collection passes, an
OutOfMemoryException is thrown.

Finalizers
A class could expose a finalizer, which executes when the object is destroyed. In C#, the finalizer is a protected method as shown below.

protected void Finalize()
{
base.Finalize();
// clean external resources
}

The method Finalize(), is only called by the .NET framework.

C#, will generate a code to a well formed Finalizer, if we declare a destructor as shown


~class1
{
// Clean external resources.
}



Declaring a Finalize method and destructor in a class, will lead to an error.


Dispose
Instead of declaring a Finalizer, exposing a Dispose method is considered as good.

If we clean up a object, using Dispose or Close method, we should indicate to the runtime that the object is no longer needed finalization, by calling GC.SuppressFinalize() as shown below:


public void Dispose()
{
// all clean up source code here..
GC.SuppressFinalize(this);
}

Wednesday, May 6, 2009

Side-by-Side Execution of .NET Framework 1.0 and 1.1

Side-by-side execution is the ability to install multiple versions of code so that an application can choose which version of the common language runtime or of a component it uses. Subsequent installations of other versions of the runtime, an application, or a component will not affect applications already installed.

In ASP.NET, applications are said to be running side by side when they are installed on the same computer, but use different versions of the .NET Framework. The following topic describes how to configure ASP.NET applications for side-by-side execution and provides detailed steps to:

Traditionally, when a component or application is updated on a computer, the older version is removed and replaced with the newer version. If the new version is not compatible with the previous version, this usually breaks other applications that use the component or application. The .NET Framework provides support for side-by-side execution, which allows multiple versions of an assembly or application to be installed on the same computer at the same time. Because multiple versions can be installed simultaneously, managed applications can select which version to use without affecting applications that use a different version.

Reference: http://www.asp.net/learn/whitepapers/side-by-side-with-1.0/

Thursday, April 30, 2009

CLR



The .NET Framework provides a runtime environment called the Common Language Runtime or CLR (similar to the Java Virtual Machine or JVM in Java), which handles the execution of code and provides useful services for the implementation of the program.

The Common Language Runtime is the underpinning of the .NET Framework. CLR takes care of code management at program execution and provides various beneficial services such as memory management, thread management, security management, code verification, compilation, and other system services. The managed code that targets CLR benefits from useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging.

Common Type System (CTS) describes how types are declared, used and managed in the runtime and facilitates cross-language integration, type safety, and high performance code execution.

The Common Language Specification (CLS) is an agreement among language designers and class library designers to use a common subset of basic language features that all languages have to follow.


Reference: http://www.arunmicrosystems.netfirms.com/clr.html

Wednesday, April 15, 2009

Profile VS. Session

I would like to point out some of the similarities/differences bewteen both Session and Profile objects:

Profile:

1- Profile object is scoped to a particular user:
Each user of a web application automatically has his own profile.

2- Profile object is persistant:
When you modify the stat os the profile object, the modifications are saved between visits to the website

3- Profile object uses the provider model to store information:
By default, the contents of a user profile are automatically saved to a Microsoft SQL Server Express database
located in App_Data of your web application.

4- Profile object is strongly typed:
Using strongly typed properties has several advantages. For example, you get full Microsoft IntelliSense when
using the Profile object in VS.NET 2005 or Visual Web Developer


Session:

1- Session object is scoped to a particular user:
Each user of a web application automatically has his own Session state.

2- Session object is non-persistant:
When you add an item to the Session object, the items disappear after you leave the Web site.

3- Session object uses three different ways to be stored:
3.1:
In Process - default
3.2:
State Server (Out of Process)
3.3: SQL Server

4- Session object is not strongly typed:
Sessopn object is simply a collection of items.

Monday, April 13, 2009

Framework Differences

Framework 2.0

C# 2.0
  • generics
  • Partial Classes
  • Anonymous methods
  • Nullable type
  • Iterating over collections
  • Static Classes
  • Property accessor accessibility-Diiferent Accesors for Get and Set
  • System.IO.Ports ->Supply the SerialPort class to implement serial port operation.
  • System.IO.Compression -> Implement compression and decompression operation on files.
  • System.Net.NetworkInformation -> Gather information about network events, changes, statistics, and properties.
  • System.Security.AccessControl -> Provide programming elements used to control access to and audit security-related actions on securable objects.

General 2.0
  • 64-bit support
  • Click once deployement
  • Runtime debug and modify.

ASP.Net 2.0
  • ASP.NET WebParts
  • Richer ASP.NET controls which leads to quicker development cycles.
  • Master Pages
  • Themes and Skins
  • Introduction of new controls like GridView FormView DetailsView4.
  • dynamic menu
  • Navigation Controls.
  • classes in app_data folder that makes the classes define in it to be as a Compiled dll.
  • Compilation model: With 1.1, all code was compiled into one assembly placed in the bin directory. With 2.0, the assembly is separated into multiple assemblies. These multiple assemblies may be created on-the-fly or precompiled. Examples of multiple assemblies are one assembly for each ASP.NET directory like App_Code and App_Data as well as individual assemblies for Web Forms, User Controls, and so forth. This is a major shift in the application structure; it offers more deployment options in how the application is delivered to the users.
  • Built in Security engine and Profile Object (user profile persisted between sessions)
  1. Microsoft ASP.NET 2.0 supports a new object called the Profile object. We can store any type of information within a user profile including both simple data types such as strings and integers and complex types such as custom objects.
  2. The Profile object is similar to the Session object, but better. Like the Session object, In other words, each user of a Web application automatically has their own profile.
  3. However, unlike the Session object, the Profile object is persistent. When you add an item to the Session object, the item disappears after you leave the Web site. When you modify the state of the Profile object, in contrast, the modifications are saved between visits to the Web site

Framework 3.0
  • system.speech namespace, which contains Windows Desktop Speech technology types for implementing speech recognition.
  • Debugger Edit and Continue (enables a user who is debugging anapplication in Visual Studio to make changes to source code while executing in Break mode. After source code edits are applied, the user can resume code execution and observe the effect. ) With the release of 3.0 the .net framework 1.1 won't be patched
  • Windows Communication Foundation (WCF), formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.
  • Windows Presentation Foundation (WPF), formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.
  • Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.

Framework 3.5

It implement Linq evolution in language. So we have the following evolution in class:
  • Linq for SQL, XML, Dataset, Object
  • Automatic Properties, Object Initializer and Collection Initializers
  • Extension Methods
  • Lambda Expressions
  • Anonymous Types
  • Active directory
  • ASP.NET Ajax
  • Paging support for ADO.NET
  • ADO.NET synchronization API to synchronize local caches and server side datastores
  • Asynchronous network I/O API
  • Support for HTTP pipelining and syndication feeds





Wednesday, April 8, 2009

Onmouseover Changing header background color of accordian control

ASPX page code
<ajax:Accordion ID="MyAccordion" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader"
ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40"
TransitionDuration="250" RequireOpenedPane="true" Width="100%" SuppressHeaderPostbacks="true">
<Panes>
<ajax:AccordionPane ID="AccordionPane1" runat="server">
<Header>
Login
</Header>
<Content>
Content 1 goes here
</Content>
</ajax:AccordionPane>
<ajax:AccordionPane ID="AccordionPane2" runat="server">
<Header>
Change password
</Header>
<Content>
Content 2 goes here
</Content>
</ajax:AccordionPane>
</Panes>
</ajax:Accordion>

Add the following script
here 'ctl00_ContentPlaceHolder1_MyAccordion_AccordionExtender' is used to access the accordian control.general way of accessing accordian control through jquery is as follows
$find('your accordian controls client id_AccordionExtender');
AccordionExtender is coomon so only change the client id while accessing your accordian control.

<script type="text/javascript">
function pageLoad()
{
//alert('in');
AddMouseOverToAccordion();
}


function AddMouseOverToAccordion()
{
var acc = $find('ctl00_ContentPlaceHolder1_MyAccordion_AccordionExtender');
//alert(acc.get_Count());
for(paneIdx = 0; paneIdx < acc.get_Count(); paneIdx++)
{
var k = null;
var j = null;
j= acc.get_Pane(paneIdx).header;
k = Function.createDelegate(this, this._onTitleHover);
$addHandler(j, "mouseover", k);

k = Function.createDelegate(this, this._onTitleHoverOut);
$addHandler(j, "mouseout", k);
}
}
function _onTitleHoverOut(e) {
e.target.style.background = "#2E4d7B";
e.target.style.color = "white";
}

function _onTitleHover(e) {
e.target.style.background = "#FFF8DC";
e.target.style.color = " #4B0082";
}

</script>

Tuesday, March 31, 2009

Dispose and Finalize in C#

When the .NET framework instantiates an object, it allocates memory for that object on the managed heap. The object remains on the heap until it's no longer referenced by any active code, at which point the memory it's using is "garbage," ready for memory deallocation by the .NET Garbage Collector (GC). Before the GC deallocates the memory, the framework calls the object's Finalize() method, but developers are responsible for calling the Dispose() method.

The two methods are not equivalent. Even though both methods perform object cleanup

The .NET garbage collector manages the memory of managed objects (native .NET objects) but it does not manage, nor is it directly able to clean up unmanaged resources. Managed resources are those that are cleaned up implicitly by the garbage collector. You do not have to write code to release such resources explicitly. In contrast, you must clean up unmanaged resources (file handles, database collections, etc.) explicitly in your code.

There are situations when you might need to allocate memory for unmanaged resources from managed code. As an example, suppose you have to open a database connection from within a class. The database connection instance is an unmanaged resource encapsulated within this class and should be released as soon as you are done with it. In such cases, you'll need to free the memory occupied by the unmanaged resources explicitly, because the GC doesn't free them implicitly.

Briefly, the GC works as shown below:

* It searches for managed objects that are referenced in managed code.
* It then attempts to finalize those objects that are not referenced in the code.
* Lastly, it frees the unreferenced objects and reclaims the memory occupied by them.

The GC maintains lists of managed objects arranged in "generations." A generation is a measure of the relative lifetime of the objects in memory. The generation number indicates to which generation an object belongs. Recently created objects are stored in lower generations compared to those created earlier in the application's life cycle. Longer-lived objects get promoted to higher generations. Because applications tend to create many short-lived objects compared to relatively few long-lived objects, the GC runs much more frequently to clean up objects in the lower generations than in the higher ones.

Finalizers—Implicit Resource Cleanup
Finalization is the process by which the GC allows objects to clean up any unmanaged resources that they're holding, before the actually destroying the instance. An implementation of the Finalize method is called a "finalizer." Finalizers should free only external resources held directly by the object itself. The GC attempts to call finalizers on objects when it finds that the object is no longer in use—when no other object is holding a valid reference to it. In other words, finalizers are methods that the GC calls on "seemingly dead objects" before it reclaims memory for that object.

Note that you cannot call or override the Finalize method. It is generated implicitly if you have a destructor for the class. This is shown in the following piece of C# code:—

   class Test
{

// Some Code

~Test
{
//Necessary cleanup code
}
}


The Dispose Method—Explicit Resource Cleanup
Unlike Finalize, developers should call Dispose explicitly to free unmanaged r
esources. In fact, you should call the Dispose method explicitly on any object
that implements it
to free any unmanaged resources for which the object may be
holding references. The Dispose method generally doesn't free managed
memory—typically, it's used for early reclamation of only the unmanaged
resources to which a class is holding references. In other words,
this method can release the unmanaged resources in a deterministic fashion.

However, Dispose doesn't remove the object
itself from memory. The object will be removed when the garbage
collector finds it convenient. It should be noted that the developer
implementing the Dispose method must call GC.SuppressFinalize(this)
to prevent the finalizer from running.

The following code illustrates how to implement the Dispose method on
a class that implements the IDisposable interface:



class Test : IDisposable
{
private bool isDisposed = false;

~Test()
{
Dispose(false);
}

protected void Dispose(bool disposing)
{
if (disposing)
{
// Code to dispose the managed resources of the class
}
// Code to dispose the un-managed resources of the class

isDisposed = true;
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}


The Dispose/Finalize Pattern
Microsoft recommends that you implement both Dispose and Finalize when working
with unmanaged resources. The correct sequence then would be for a
developer to call Dispose. The Finalize implementation would run and the
resources would still be released when the object is garbage collected
even if a developer neglected to call the Dispose method explicitly.

Simply put, cleanup the unmanaged resources in the Finalize method and the
managed ones in the Dispose method, when the Dispose/Finalize pattern has been
used in your code.

As an example, consider a class that holds a database connection instance.
A developer can call Dispose on an instance of this class to release the
memory resource held by the database connection object. After it is freed,
the Finalize method can be called when the class instance needs to be
released from the memory.

Reference: http://www.devx.com/dotnet/Article/33167

using Statement

Defines a scope, outside of which an object or objects will be disposed.

using (Font font1 = new Font("Arial", 10.0f))
{
}

C#, through the .NET Framework common language runtime (CLR), automatically releases the memory used to store objects that are no longer required. The release of memory is non-deterministic; memory is released whenever the CLR decides to perform garbage collection. However, it is usually best to release limited resources such as file handles and network connections as quickly as possible.

The using statement allows the programmer to specify when objects that use resources should release them. The object provided to the using statement must implement the
IDisposable interface. This interface provides the Dispose method, which should release the object's resources.

A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end of the statement.

Multiple objects can be used in with a using statement, but they must be declared inside the using statement, like this:

using (Font font3 = new Font("Arial", 10.0f), font4 = new Font("Arial", 10.0f))
{
// Use font3 and font4.
}


Example:
The following sample shows how a user-defined class can implement its own Dispose behavior. Note that your type must inherit from IDisposable.

using System;

class C : IDisposable
{
public void UseLimitedResource()
{
Console.WriteLine("Using limited resource...");
}

void IDisposable.Dispose()
{
Console.WriteLine("Disposing limited resource.");
}
}

class Program
{
static void Main()
{
using (C c = new C())
{
c.UseLimitedResource();
}
Console.WriteLine("Now outside using statement.");
Console.ReadLine();
}
}


The new code would looking something like this:

using (SqlConnection cn = new SqlConnection(connectionString))
{
using (SqlCommand cm = new SqlCommand(commandString, cn))
{
cn.Open();
cm.ExecuteNonQuery();
}
}

This is essentially equivalent to the following, although my guess is that C# will internally generate two try / finally blocks (one for the SqlConnection and one for the SqlCommand), but you get the idea:

SqlConnection cn = null;
SqlCommand cm = null;

try
{
cn = new SqlConnection(connectionString);
cm = new SqlCommand(commandString, cn);
cn.Open();
cm.ExecuteNonQuery();
}
finally
{
if (null != cm);
cm.Dispose();
if (null != cn)
cn.Dispose();
}


Reference :http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx

Monday, December 22, 2008

Strong names and Signing

What is a strong name?

A strong name is a .NET assembly name combined with its version number and other information to uniquely identify the assembly. This allows multiple versions of the same assembly to peacefully co-exist in the global assembly cache, where shared assemblies are typically stored.

A strong name consists of five parts:

  1. Simple Name - Usually the name of the file (without the extension) that contains the assembly
  2. Public Key - RSA cryptographic public key that helps verify the assembly’s authenticity
  3. Version - Four-part version number, in the form of Major.Minor.Build.Revision
  4. Culture - Target audience for the assembly, such as “neutral” (default audience), “en-us” (English - United States) or “fr” (France) etc.
  5. Processor Architecture - Defines the assembly’s format, such as MSIL (intermediate language) or x86 (binary for Intel x86 processors)

An example strong name is “Mini-Launcher, Version=0.3.612.24542, Culture=neutral, PublicKeyToken=ffa52ed9739048b4, ProcessorArchitecture=MSIL”.

Why use strong names?

Strong names are required to store shared assemblies in the global assembly cache (GAC). This is because the GAC allows multiple versions of the same assembly to reside on your system simultaneously, so that each application can find and use its own version of your assembly. This helps avoid DLL Hell, where applications that may be compiled to different versions of your assembly could potentially break because they are all forced to use the same version of your assembly.

Another reason to use strong names is to make it difficult for hackers to spoof your assembly, in other words, replace or inject your assembly with a virus or malicious code.

What is a strong name key file?

A strong name key file has a .snk extension and contains a unique public-private key pair. You use the strong name key file to digitally sign your assembly (see below). Note that this type of file is not secure, as the private key in a .snk file can be easily compromised.

For added protection, Visual Studio can encrypt a strong name key file, which produces a file with the .pfx (Personal Information eXchange) extension. The .pfx file is more secure because whenever someone attempts to use the encrypted key, she will be prompted for the password.

How do I create a strong name key file for a .NET assembly?


Reference : http://www.csharp411.com/net-assembly-faq-part-3-strong-names-and-signing/

Design Guidelines in .NET Framework

Follow all .NET Framework Design Guidelines for both internal and external members. Highlights of these include:

* Do not use Hungarian notation
* Do not use a prefix for member variables (_, m_, s_, etc.). If you want to distinguish between local and member variables you should use “this.” in C# and “Me.” in VB.NET.
* Do use camelCasing for member variables
* Do use camelCasing for parameters
* Do use camelCasing for local variables
* Do use PascalCasing for function, property, event, and class names
* Do prefix interfaces names with “I”
* Do not prefix enums, classes, or delegates with any letter


Reference : http://blogs.msdn.com/brada/articles/361363.aspx

C# Array Functions

Array.ConvertAll- Convert integer array to string array

private void TestMethod(int[] intArray)

{

string[] stringArray =

Array.ConvertAll<int,string>

(intArray,new Converter<int,string>

(ConvertIntToString));

string result = string.Join(",", stringArray);

}

private string ConvertIntToString(int intParameter)

{

return intParameter.ToString();

}


Array.Resize

int[] zArray = { 1, 2, 3, 4 };

Array.Resize<int>(ref zArray, 8);


Array.ConstrainedCopy Method

Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.


Array.AsReadOnly Method

Returns a read-only wrapper for the specified array.

Wednesday, December 17, 2008

Concept Differences

Difference between Events & Delegates

Events are the actions of the system on user manipulations (e.g. mouse clicks, key press, timer etc.) or any event triggered by the program.

Delegate is type which holds the method(s) reference in an object. It is also refered as a type safe function pointers.

What is the difference between a Thread and Process?

A process is a collection of virtual memory space, code, data, and system resources. A thread is code that is to be serially executed within a process. A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread. Prior to the introduction of multiple threads of execution, applications were all designed to run on a single thread of execution.

When a thread begins to execute, it continues until it is killed or until it is interrupted by a thread with higher priority (by a user action or the kernel’s thread scheduler). Each thread can run separate sections of code, or multiple threads can execute the same section of code. Threads executing the same block of code maintain separate stacks. Each thread in a process shares that process’s global variables and resources.

Difference between Struct and Class
Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap.
Struct “do not support” inheritance, while class supports inheritance. However struct can implements interface.
Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.

What is the difference between the destructor and the Finalize() method? When does the Finalize() method get called?

Finalize() corresponds to the .Net Framework and is part of the System.Object class. Destructors are C#'s implementation of the Finalize() method. The functionality of both Finalize() and the destructor is the same, i.e., they contain code for freeing the resources when the object is about to be garbage collected. In C#, destructors are converted to the Finalize() method when the program is compiled. The Finalize() method is called by the .Net Runtime and we can not predict when it will be called. It is guaranteed to be called when there is no reference pointing to the object and the object is about to be garbage collected.

Value and Reference Type
Value Type
As name suggest Value Type stores “value” directly.
Stored in a Stack

For each instance of value type separate memory is allocated.

It Provides Quick Access, because of value located on stack.

Eg: int, float, char, decimal, bool, decimal, struct, etc are value types, while object type such as class, String, Array, etc are reference type.

Reference Type
As name suggest Reference Type stores “reference” to the value.

Reference type are stored on Heap.
It provides comparatively slower access, as value located on heap.

Out and Ref.

ref keyword
Passing variables by value is the default. However, we can force the value parameter to be passed by reference. Note: variable “must” be initialized before it is passed into a method.

out keyword
out keyword is used for passing a variable for output purpose. It has same concept as ref keyword, but passing a ref parameter needs variable to be initialized while out parameter is passed without initialized.

It is useful when we want to return more than one value from the method.

Note: You must assigned value to out parameter in method body, otherwise the method won’t compiled.


System.Array.CopyTo() Vs. System.Array.Clone()
The
Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.



Jagged Arrays In C#

A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." The following examples show how to declare, initialize, and access jagged arrays.

// Single-dimensional array
int[] numbers = new int[5];

// Multidimensional array
string[,] names = new string[5,4];

// Array-of-arrays (jagged array)
int[][] jaggedArray = new int[3][];

jaggedArray[0] = new int[5];
jaggedArray[1] = new int[4];
jaggedArray[2] = new int[2];

Reference:
http://msdn.microsoft.com/en-us/library/2s05feca.aspx

Friday, October 31, 2008

Proxy Classes

When accessing Caché data through the CMP object interface, a .net client object interacts directly with a set of .net proxy classes. The proxy classes represent the Caché classes executing on the Caché server. Generally, a .net application will contain one proxy class for each Caché class that the application accesses. These proxy classes use a set of helper classes, contained in the InterSystems.Data.CacheClient.dll assembly, to forward the application's requests to the Caché objects on the Caché server. The Caché objects, in turn, use the helper classes and proxies to return messages to the .net client.


Reference: http://vista.intersystems.com/csp/docbook/DocBook.UI.Page.cls?KEY=TCMP_ProxyClasses

Monday, September 15, 2008

XML Comments in C#

XML comments are added to source code by prefixing the XML comment lines with three forward slashes. Visual Studio will automatically insert a documentation template whenever three forward slashes are typed within a C# source code file. Visual Studio's intellisense system also works within XML comments, using the comments to enhance the information presented about a class, constructor or other member.

An example of a function documented with XML comments is shown below:

/// <summary>
///<para>Non-HTML files like Adobe Acrobat PDF files and Word
///documents are stored with their original URLs partially
///encoded in their filenames. This function will return the
///original URL of the file.</para>
///<para>The encoding done by the Index Server Companion removes
///characters that cannot be present in Windows filenames
///(these are: \/:*?"<>|). The decoding performed is:</para>
/// <list type="table">
/// <listheader><term>Find</term><description>Replace</description></listheader>
/// <item><term>^f</term><description>\</description></item>
/// <item><term>^b</term><description>/</description></item>
/// <item><term>^c</term><description>:</description></item>
/// <item><term>^s</term><description>*</description></item>
/// <item><term>^q</term><description>?</description></item>
/// <item><term>^d</term><description>\</description></item>
/// <item><term>^l</term><description><</description></item>
/// <item><term>^g</term><description>></description></item>
/// <item><term>^p</term><description>|</description></item>
/// </list>
/// </summary>
/// <param name="FileName">The document's original filename.</param>
/// <returns>Decoded filename</returns>
/// <exception cref="System.Exception">Throws an exception when something goes wrong.</exception>
private string CreateURLFromFileName(string FileName)
{

}




To get the resulting XML Documentation file, we call the csc compiler with the /doc option.
csc /doc:HelloWorld.xml helloworld.cs

HTML Web Pages
You may be asking yourself: how do I get nicely formatted web pages? Well, you could write your own XSL to transform the XML documentation file, or you could use Visual Studio.NET. By using the Tools -> Build Comment Web Pages option, you can get a set of html files detailing your entire project or solution. Here is a screen shot by building web pages for our HelloWorld example:

Predefined Tag Used for
<c> a way to indicate that text within a description should be marked as code
<code> a way to indicate multiple lines as code
<example> lets you specify an example of how to use a method or other library member
<exception> lets you document an exception class
<include> lets you refer to comments in another file, using XPath syntax, that describe the types and members in your source code.
<list> Used to insert a list into the documentation file
<para> Used to insert a paragraph into the documentation file
<param> Describes a parameter
<paramref> gives you a way to indicate that a word is a parameter
<permission> lets you document access permissions
<remarks> where you can specify overview information about the type
<returns> describe the return value of a method
<see> lets you specify a link
<seealso> lets you specify the text that you might want to appear in a See Also section
<summary> used for a general description
<value> lets you describe a property

Reference : http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article=21
http://www.winnershtriangle.com/w/Articles.XMLCommentsInCSharp.asp

Friday, September 12, 2008

Wireless Markup Language(WML)

Wireless Markup Language, based on XML, is a markup language intended for devices that implement the Wireless Application Protocol (WAP) specification, such as mobile phones, and preceded the use of other markup languages now used with WAP, such as XHTML and even standard HTML (which are gaining in popularity as processing power in mobile devices increases).

WML markup
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml" >
<wml>
<card id="main" title="First Card">
<p mode="wrap">This is a sample WML page.</p>
</card>
</wml>

Wireless Markup Language is a lot like HTML (Hyper Text Markup Language) in that it provides navigational support, data input, hyperlinks, text and image presentation, and forms. A WML document is known as a “deck”. Data in the deck is structured into one or more “cards” (pages) – each of which represents a single interaction with the user. The introduction of the terms "deck" and "card" into the internet and mobile phone communities was a result of the user interface software and its interaction with wireless communications services having to comply with the requirements of the laws of two or more nations.

WML decks are stored on an ordinary web server trivially configured to serve the text/vnd.wap.wml MIME type in addition to plain HTML and variants. The WML cards when requested by a device are accessed by a bridge WAP gateway, which sits between mobile devices and the World Wide Web, passing pages from one to the other much like a proxy. The gateways radio the WML pages in a form suitable for mobile device reception. This process is hidden from the phone, so it may access the page in the same way as a browser accesses HTML, using a URL (for example, http://example.com/foo.wml), provided the mobile phone operator has not specifically locked the phone to prevent access of user-specified URLs.

Reference : http://en.wikipedia.org/wiki/Wireless_Markup_Language

Wednesday, September 10, 2008

XSLT(Extensible Stylesheet Language transformation)

Extensible Stylesheet Language transformation (XSLT) is a language for transforming XML documents into other XML documents. XSLT is designed for use as part of XSL, which is a stylesheet language for XML.

Reference: http://www.topxml.com/dotnet/articles/xslt/default.asp

TCP/IP,SMTP,SSL,DNS

TCP/IP
A communication protocol is a description of the rules computers must follow to communicate with each other. The Internet communication protocol defines the rules for computer communication over the Internet.

As with all other communications protocol, TCP/IP is composed of layers:

* IP - is responsible for moving packet of data from node to node. IP forwards each packet based on a four byte destination address (the IP number). The Internet authorities assign ranges of numbers to different organizations. The organizations assign groups of their numbers to departments. IP operates on gateway machines that move data from department to organization to region and then around the world.
* TCP - is responsible for verifying the correct delivery of data from client to server. Data can be lost in the intermediate network. TCP adds support to detect errors or lost data and to trigger retransmission until the data is correctly and completely received.
* Sockets - is a name given to the package of subroutines that provide access to TCP/IP on most systems.


SMTP


SMTP


Digg This! StumbleUpon Toolbar StumbleUpon Bookmark with Delicious Del.icio.us

DEFINITION - SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving e-mail. However, since it is limited in its ability to queue messages at the receiving end, it is usually used with one of two other protocols, POP3 or IMAP, that let the user save messages in a server mailbox and download them periodically from the server. In other words, users typically use a program that uses SMTP for sending e-mail and either POP3 or IMAP for receiving e-mail. On Unix-based systems, sendmail is the most widely-used SMTP server for e-mail. A commercial package, Sendmail, includes a POP3 server. Microsoft Exchange includes an SMTP server and can also be set up to include POP3 support.

SMTP usually is implemented to operate over Internet port 25. An alternative to SMTP that is widely used in Europe is X.400. Many mail servers now support Extended Simple Mail Transfer Protocol (ESMTP), which allows multimedia files to be delivered as e-mail.

SSL
(pronounced as separate letters) Short for Secure Sockets Layer, a protocol developed by Netscape for transmitting private documents via the Internet. SSL uses a cryptographic system that uses two keys to encrypt data − a public key known to everyone and a private or secret key known only to the recipient of the message. Both Netscape Navigator and Internet Explorer support SSL, and many Web sites use the protocol to obtain confidential user information, such as credit card numbers.By convention, URLs that require an SSL connection start with https: instead of http:.

Another protocol for transmitting data securely over the World Wide Web is Secure HTTP (S-HTTP). Whereas SSL creates a secure connection between a client and a server, over which any amount of data can be sent securely, S-HTTP is designed to transmit individual messages securely. SSL and S-HTTP, therefore, can be seen as complementary rather than competing technologies. Both protocols have been approved by the Internet Engineering Task Force (IETF) as a standard.

DNS
The Domain Name System (DNS) is a hierarchical naming system for computers, services, or any resource participating in the Internet. It associates various information with domain names assigned to such participants. Most importantly, it translates humanly-meaningful domain names to the numerical (binary) identifiers associated with networking equipment for the purpose of locating and addressing these devices world-wide.