Archive for the '.NET Framework' Category
.NET Framework 4 File IO Features
New methods are added to the System.IO.File class in .NET framework 4.0 for reading and writing text files.
ReadLines
In earlier version we have used File.ReadAllLines method which returns a string array of all lines in the file.
String[] lines = File.ReadAllLines(“file.txt”);
Related Posts:
1 comment.NET Framework 4 SortedSet
You can get the overview on what’s new in .NET FW BCL by reading my post .NET Framework 4 BCL. This post explains about one of the feature SortedSet. .NET Framework 4 adds a new collection to System.Collections.Generic, named Sorted Set<T>. It is like HashSet<T> collection of unique elements, but SortedSet<T> keeps the elements in sorted order.
The Collection is implemented using red-black tree datastructure. Compared to HashSet<T> provides lesser performance for insert,delete and lookup operations. Use this collection if you want to keep the elements in sorted order.
Related Posts:
No comments.NET Framework 4 BCL
All .NET developers who uses the BaseClassLibraries can read this post to know what’s New in the .NET FW 4 BCL. Its not the scope of this post to cover all the features but you can read them on BCL team blog at blogs.msdn.com/bclteam.
The following are the features that you can explore in BCL
- Code Contracts
- Parallel extensions
- Tuples
- File IO improvements
- Memory mapped files
- Sorted Set Collection
Code Contracts
One of the major features added to the .NET FW BCL in version 4 is code contracts. Classes and methods should explicitly state that what they require and what they guarantee if those requirements are met, i.e. their contracts.
Related Posts:
2 commentsDocumenting C# code with XML Comments
This article explains an easy and effective way of documenting your C# code. XML comments are the solution for generating a clean documentation for your code. Visual Studio environment allows you to generate a documentation file for your project. It helps your teammates and other people who using your code.
This post will explain how to use XML comments in code and how to generate XML help documents from those comments.
XML Comment Basics
XML comments can be used to all types except namespaces. The types can be Class,Module,Interface, Enum, properties, events and methods.
XML comments are inserted inline, directly in your source code. To insert an XML comment type three single “///” immediately above definition.
Related Posts:
No commentsGAC in .NET Framework
The Global Assembly Cache known as the GAC is to enable sharing of assemblies across several managed applications installed on a machine. All managed developers can install assemblies to the GAC and share them across applications.
When to Use the GAC
When should an assembly be installed in the GAC as opposed to assembly in application base? If you have any assembly that must be shared across multiple applications and hence centrally serviced. Shared frameworks and components typically fall under this category.
It is a machinewide repository of managed assemblies.
When shouldn’t an assembly be placed in the GAC? If you need the application to be xcopy deployable on different machines, placing the assembly in the GAC is probably not best idea. In this case the assemblies in the GAC will also need to be moved across machines.
Binder follows the “GAC always wins” policy.
GACUtil is a tool used to install, uninstall the assemblies to and from the GAC.
This tool ship with .NET Framework SDK. In .NET Framework 4.0, the GAC went through a few changes. The GAC was split into two, one for each CLR.
The CLR version used for both .NET Framework 2.0 and .NET Framework 3.5 is CLR 2.0. There was no need in the previous two framework releases to split GAC. The problem of breaking older applications in Net Framework 4.0.
To avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.
Related Posts:
No commentsAssembly binding in .NET Framework
The CLR is responsible for locating and binding the assemblies in the code. In Order to work assembly binding efficiently you need to follow some best practices.
Assembly Naming
Always use fully specified assembly names. An assembly name is a name given to unique identity. Two assemblies representing the same identity can have the same name with different versions.
Assemblies are mostly loaded by it’s name and keeping the names consist makes it easier for the loader to find the assembly. A fully qualified assembly consist of four fields:
- Name of the assembly
- The version
- The culture
- The public key token
Partial Binding
Related Posts:
No commentsVisual Studio 2010 Beta 1 and .NET FW 4.0 Beta 1 Released!
Yesterday Visual Studio 2010 Beta1 and .NET FW 4.0 Beta 1 was released and you can download it from here. Download Beta 1.
More about Highlights in VS 2010 Beta1 can found in Jason Blog.
Enhancements in ASP.NET and discussions on latest version here
Feedback, Questions related to VS 2010 can be found here
Next posts I am going to discuss more on the highlights in VS 2010
Related Posts:
No commentsVisual Studio 2008 SP1 Features
Introduction
Visual Studio 2008 service pack 1(SP1) and .NET Framework 3.5 SP1 offers the developers to develop rapid,responsiveness and stable applications. It allows the developers to develop applications that optimized for windows vista, SQL server, MS 2007 office system and the web.
Features Overview
- WPF Designers
- SQL Server 2008 support
- ADO.NET Entity Designer
- TFS enhancements
- Performance enhancements
You can download the Visual Studio 2008 SP1.
Note: When you are installing Visual Studio 2008 on Windows Vista it fails the installation.
To Resolve this issue
1. Right-click the Sidebar icon in the notification area, at the far right of the taskbar.
2. Click "Exit".
Related Posts:
1 commentWCF Sample in Visual studio 2008
Introduction
This post explains the procedure to develop the sample WCF Service and WCF Client in Visual studio 2008. Get an overview on WCF and WCF Terms.
1. Start open Visual studio 2008, Select new project option from file menu
2. Select the WCF ServiceApplication template from the project templates.
3. WCF Service describes the operations that perform in a service contract.
4.Declare the service contract in Iservice.cs interface and implement in the above Service class.
5. To test this service, you will need to create a client and use it to call the
service. You can do this using the svcutil.exe tool from the command line with
the following syntax: Generating a client using svcutil.
svcutil.exe http://localhost:53391/Service.svc?wsdl
6. The above command generates a code file and configuration file contains the client class. Add the two files to your client application and use the generated client class to call the service.
7. Client class which call the service looks like
8. The generated client configuration file looks like
9. The service configuration file looks like
Conclusion
The above post explains shows the standard way to create a service and client and calling the service. The Next posts explains each feature in depth.
Related Posts:
7 commentsOverview of .NET Remoting
Introduction
This post provides you the overview of .NET Remoting Framework. It allows the objects to interact with one another across the application domains.
Features
- Communication channels for transporting messages across applications
- Formatters are used for encoding and decoding the messages. supported formatters are
1. Binary encoding formatter – use when performance is critical
2. XML encoding formatter = use when Interoperability is essential
- Object activation and life-time support
Object activation model falls into two categories
1.Client-activated objects
2.Server-activated objects
Remote Objects
An object is consider to be remote when the caller of the object is in different application domain. Object has to decorate with [serializable] custom attribute or they have to implement ISerializable interface to be considered as a remote. Remote objects have to be passed by value. Any object can be changed to remote by deriving from MarshalByRefObject.
Proxy Objects
Proxy Objects are created when client activates a remote object. Proxy object acts as a representative to remote object and ensures that all calls that made on proxy are forwarded to the remote object.
Two types of Proxy Objects
1.Transparent Proxy
2.Real Proxy
when client activates a remote object, Framework creates a local instance of TransparentProxy class. All method calls on Transparent Proxy object are intercepted by CLR and forwards the call if the remote object is in same application domain.
Real Proxy object calls are intercepted by CLR and forwards the call even the remote object is in different application domain by calling its Invoke method.


![Recommend [kalyanms1]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)