.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 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 commentsCreating Custom Activities in Windows Workflow Foundation
Introduction
Activities are basic units in workflow execution. Activities are two types basic activities and composite activities. Basic activities are steps in the workflow and composite activities can contain other activities.
Base activities are comes with Workflow Foundation and these can be used by dragging it from visual studio toolbox. We can also create custom activities that appear in the visual studio toolbox.
Activities are like classes and we can define properties, methods and events.
We can build an activity or multiple activities into .NET assembly and deploy them as re-usable assemblies.
In this post we will learn how to create custom activities and properties in workflow foundation.
Create a workflow project
1. Create a workflow project by selecting the File->New->Project menu command and it displays a dialogue box select the Sequential Workflow Console Application template and click ok.
2. Rename the Workflow1.cs workflow to SendMailWorkflow.cs.
Create an Activity Project
1. Add new project to the existing solution by selecting the Add new project option. select the Workflow Activity Library template from the dialogue box.
2. Enter the SendMailActivityLibrary in the name field and visual studio creates a active library project.
3. Rename the single activity named ativity1 to SendMailActivity.
4. Click on the SendMailActivity in the workarea to view the properties window.
Related Posts:
4 comments.NET Framework Features
.NET Framework 1.1/2.0/3.0/3.5 main features comparision
1.1
Side-by-Side Execution
ASP.NET Mobile Controls
IPv6 Support
2.0
64-Bit Platform Support
Click-Once Deployment
Strongly-Typed Application Settings
Related Posts:
No comments
![Recommend [kalyanms1]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)