Using keyword in C#
Introduction
Using keyword in C# can be used as directive and as well as statement.
When you use using as Directive you will get the following advantages
- You can use the types in a namespace by declaring with using keyword.
example: using Systetm.Web;
- You can define a alias for the nested namespaces
example: using alias = CompanyName.ProjectName;
When you use using as Statement it defines the scope and allows the programmer to release the resources used by the object in the defined scope.
The object mentioned in the using statement must implement IDisposable interface. A using statement is can be exited when the end of the using statement is reached.
example :
Font font2 = new Font("Arial", 10.0f);
using (font2)
{
// use font2
}
Multiple objects can be used in with a using statement, but they must
be declared inside the using statement.
example:
using (ResourceType r1 = e1, r2 = e2, …, rN = eN) statement
it is equivalent to the following code
No commentsusing (ResourceType r1 = e1)
using (ResourceType r2 = e2)…
using (ResourceType rN = eN)
statement
What is Windows Azure?
Introduction
Windows Azure is an operating system for windows cloud. This post speaks about key features and how can we use windows Azure.
No commentsNew .NET Logo
Microsoft officially announced new logo for Visual studio suite at PDC 2008.
The logo is on light background and dark background.
Why this logo?
It stands for consistency, robustness and greater user experiences. It is reflected in newer brands such as silver light, surface and more. The letter āNā in the logo will become shorthand for the .NET brand name.
No commentsThe Future of C#
Introduction
This post speaks about the future of C# which presented by Anders Hejlsberg chief architect of C# at PDC 2008. The coming version C#4.0 is much concerned on introducing Functional and Dynamic programming language concepts into the C#. It also speaks about C#4.0 features.
The factors that shape the C#4 are
- Declarative programming
- Dynamic programming
- Concurrence programming
Microsoft Health COMMON USER INTERFACE
Introduction
The Microsoft Health Common User Interface (CUI) provides a toolkit with controls which addresses wide range of patient safety concerns for Health Care Organizations all over the world. This tool kit allows the developers to build a new generation of Health Care Applications.
With Microsoft CUI you can
- Quickly and easily develop a Health Care Application
- Design guidance for developing the applications
- Develop applications in Visual Studio Environment
Microsoft developing all these controls using Windows Presentation Foundation and Silver light 2.0 technology.
Microsoft Demonstrated the Features of this controls by developing a patient journey application in NHS 2008 summit.
The following are some of the screen shots of the Application
- Dynamic Search and Results slider
Overview on SharePoint 2007 Features
Introduction
This post explains the SharePoint 2007 features which helps the end users to understand the benefits of MOSS.
Document Library One of the most used features of SharePoint is the document library. It allows the users to manage documents by uploading them to libraries and manage rows and columns of information which is similar to spreadsheet.
Lists another interesting feature in SharePoint 2007(MOSS) which composed of rows and columns much like spreadsheet. Different types of lists in SharePoint are Announcements, Contacts, Discussion Board, Links, Calendar, Tasks, Project Tasks, Survey and Custom Lists.
No commentsBusiness Needs for SharePoint 2007
A number of organizational needs made the adoption of SharePoint technologies. Some of the common business needs to use SharePoint 2007.
- Document Management Includes document versioning, check-out and check-in features, adding metadata to documents and a better control of document access.
- Collaboration between users To allow the users to interact efficiently with each other to share information. Integration of office applications is a key component in SharePoint.
WCF vs ASP.NET Web services
Introduction
In this post I will explain the Difference between ASP.NET web service and programming WCF services like ASP.NET web services. It also discusses how we use the both technologies for developing the web services.
The development of web service with ASP.NET relies on defining data and relies on the XmlSerializer to transform data to or from a service.
Key issues with XmlSerializer to serialize .NET types to XML
- Only Public fields or Properties of .NET types can be translated into XML.
- Only the classes which implement IEnumerable interface.
- Classes that implement the IDictionary interface, such as Hash table can not be serialized.
The WCF uses the DataContractAttribute and DataMemeberAttribute to translate .NET FW types in to XML.
[DataContract]
public class Item
{
[DataMember]
public string ItemID;
[DataMember]
public decimal ItemQuantity;
[DataMember]
public decimal ItemPrice;}
The DataContractAttribute can be applied to the class or a strcture. DataMemberAttribute can be applied to field or a property and theses fields or properties can be either public or private.
Important difference between DataContractSerializer and XMLSerializer.
- A practical benefit of the design of the DataContractSerializer is better performance over XMLserialization.
- XMLSerialization does not indicate the which fields or properties of the type are serialized into XML where as DataCotratSerializer Explicitly shows the which fields or properties are serialized into XML.
- The DataContractSerializer can translate the HashTable into XML.
Developing Service
To develop a service using ASP.NET we must add the WebService attribute to the class and WebMethodAttribute to any of the class methods.
Example
[WebService]
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string Test(string strMsg)
{
return strMsg;
}
}
To develop a service in WCF we will write the following code
[ServiceContract]
public interface ITest
{
[OperationContract]
string ShowMessage(string strMsg);
}
public class Service : ITest
{
public string ShowMessage(string strMsg)
{
return strMsg;
}
}
The ServiceContractAttribute specifies that a interface defines a WCF service contract, OperationContract Attribute indicates which of the methods of the interface defines the operations of the service contract.
A class that implements the service contract is referred to as a service type in WCF.
Hosting the Service
ASP.NET web services are compiled into a class library assembly and a service file with an extension .asmx will have the code for the service. The service file is copied into the root of the ASP.NET application and Assembly will be copied to the bin directory. The application is accessible using url of the service file.
WCF Service can be hosted within IIS or WindowsActivationService.
- Compile the service type into a class library
- Copy the service file with an extension .SVC into a virtual directory and assembly into bin sub directory of the virtual directory.
- Copy the web.config file into the virtual directory.
Client Development
Clients for the ASP.NET Web services are generated using the command-line tool WSDL.EXE.
WCF uses the ServiceMetadata tool(svcutil.exe) to generate the client for the service.
Message Representation
The Header of the SOAP Message can be customized in ASP.NET Web service.
WCF provides attributes MessageContractAttribute , MessageHeaderAttribute and MessageBodyMemberAttribute to describe the structure of the SOAP Message.
Service Description
Issuing a HTTP GET Request with query WSDL causes ASP.NET to generate WSDL to describe the service. It returns the WSDL as response to the request.
The generated WSDL can be customized by deriving the class of ServiceDescriptionFormatExtension.
Issuing a Request with the query WSDL for the .svc file generates the WSDL. The WSDL that generated by WCF can customized by using ServiceMetadataBehavior class.
Exception Handling
In ASP.NET Web services, Unhandled exceptions are returned to the client as SOAP faults.
In WCF Services, unhandled exceptions are not returned to clients as SOAP faults. A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging.
No commentsMicrosoft Web Application Installer(Beta)
Introduction
The Microsoft Web Application Installer (Web AI) allows you to install Web applications for IIS from other sources. Web AI identifies available applications and the originating Web sites, and asks you to select the application that you want to install.
What does it do?
Web AI downloads the applications that you selected directly from the originating web sites and configures according to your instructions.
Web AI is the easiest way to install the freely available PHP and ASP.NET applications on the IIS Web server.
- Web AI provides support for popular ASP.NET and PHP Web Applications including Graffiti, DotNetNuke, WordPress, Drupal, OSCommerce and more.
Host the WCF Service in IIS
Introduction
This post explains hosting the WcfEmployee Service on IIS that we previously hosted with in .NET Executable. Hosting the WCF service in IIS provides a robust, efficient and secure features to WCF service.
1. Create a virtual directory that pointing to the Employee Service project in IIS
2. Configuring the service in IIS is identical to the configuration used for hosting the service in .NET Executable. The configuration file looks like in the following window
3. Confirm the Availability of the service by browsing the .svc file in browser.
4. Run the client application to consume the service.
No comments