Skip to content

Installed Microsoft Roslyn June 2012 CTP

Today I installed latest version of Roslyn CTP. It works only with Visual Studio 2012 RC and Visual Studio 2010 SP1. You must be having Visual Studio 2010 SP1 SDK and Visual Studio 2012 RC SDK installed on your PC too then only the installation of Roslyn June 2012 CTP would start.

The Microsoft “Roslyn” CTP previews the new language object models for code generation, analysis, and refactoring, and the upcoming support for scripting and interactive use of C#. I have already studies the whitepaper “The Roslyn Project” available Now I am quite excited to experimenting on it.

Below is how this CTP installation adds the project templates:

If you also want to explore the features of Roslyn project following links will be helpful:

Introduction to Roslyn Project:

What’s New in June 2012 CTP:

Anders Hejlsberg on Roslyn Project:


Dependency Inversion Principle




The high level module should depend upon Abstractions, not depend upon concretions of lower module.




In conventional application architecture, lower-level components are designed to be consumed by higher-level components which enable increasingly complex systems to be built. In this composition, higher-level components depend directly upon lower-level components to achieve some task. This dependency upon lower-level components limits the reuse opportunities of the higher-level components.


The goal of the dependency inversion principle is to decouple high-level components from low-level components such that reuse with different low-level component implementations becomes possible. This is facilitated by the separation of high-level components and low-level components into separate packages/libraries, where interfaces defining the behavior/services required by the high-level component are owned by, and exist within the high-level component’s package. The implementation of the high-level component’s interface by the low level component requires that the low-level component package depend upon the high-level component for compilation, thus inverting the conventional dependency relationship.


Various patterns such as Plugin, Service Locator, or Dependency Injection are then employed to facilitate the run-time provisioning of the chosen low-level component implementation to the high-level component. Applying the dependency inversion principle can also be seen as applying the Adapter pattern, i.e. the high-level class defines its own adapter interface which is the abstraction that the high-level class depends on. The adoptee implementation also depends on the adapter interface abstraction (of course, since it implements its interface) while it can be implemented by using code from within its own low-level module. The high-level has no dependency to the low-level module since it only uses the low-level indirectly through the adapter interface by invoking polymorphic methods to the interface which are implemented by the adoptee and its low-level module.


Why Serialization is needed?

In my last blogpost I discussed about what is serialization and some basics about it. Now we will address following question here:

Why Serialization is needed:

In non-object-oriented languages, one would typically have data stored in memory in a pattern of bytes that would ‘make sense’ without reference to anything else. For example, a bunch of shapes in a graphics editor might simply have all their points stored consecutively. In such a program, simply storing the contents of all one’s arrays to disk might yield a file which, when read back into those arrays would yield the original data. So in non-object-oriented languages, for some limited scenario, serialization may be straight forward and no need of special serialization mechanism or formats.

In object-oriented languages, many objects are stored as references to other objects. Merely storing the contents of in-memory data structures will not be useful, because a reference to object #24601 won’t say anything about what that object represents. While an object-oriented system may be able to do a pretty good job figuring out what the in-memory data “mean” and try to convert it automatically to a sensible format, it can’t recognize all the distinctions between object references which point to the same object, and those that point to objects which happen to match. It’s thus often necessary to help out the system when converting objects to a raw stream of bits.

In this regard, more points to be considered are:

  1. Binary representations may be different between different architectures, compilers and even different versions of the same compiler. There’s no guarantee that what system A sees as a signed integer will be seen as the same on system B. Byte ordering, word lengths, struct padding etc will become hard to debug problems if you don’t properly define the protocol or file format for exchanging the data.
  2. Serializing the data structure in an architecture independent format means that we do not suffer from the problems of byte ordering, memory layout, or simply different ways of representing data structures in different programming languages.
  3. While storing information in memory is great, there comes a time your users will have to shut your application down. This means (probably) that you will need to write information to a file at some point, because you will want to store whatever data was in memory.
  4. To discourage competitors from making compatible products, publishers of proprietary software often keep the details of their programs’ serialization formats a trade secret. Some deliberately obfuscate or even encrypt the serialized data. Yet, interoperability requires that applications be able to understand each other’s serialization formats. Therefore, remote method call architectures such as CORBA define their serialization formats in detail.
  5. Writing crucial data to the disk as TEXT is always dangerous. Any anonymous user can open the text file and easily read your data. With Object Serialization, you can reduce this danger to a certain extent.

Steps in the Serialization Process in C#

When the Serialize method is called on a formatter, object serialization proceeds according to the following sequence of rules:

  • A check is made to determine whether the formatter has a surrogate selector. If the formatter does, check whether the surrogate selector handles objects of the given type. If the selector handles the object type, ISerializable.GetObjectData is called on the surrogate selector.
  • If there is no surrogate selector or if it does not handle the object type, a check is made to determine whether the object is marked with the Serializable attribute. If the object is not, a SerializationException is thrown.
  • If the object is marked appropriately, check whether the object implements the ISerializable interface. If the object does, GetObjectData is called on the object.
  • If the object does not implement ISerializable, the default serialization policy is used, serializing all fields not marked as NonSerialized.

Useful links on Serialization:

What is Serialization?

Definition of Serialization:

Serialization is the process of converting a data structure or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and “resurrected” later in the same or another computer environment. [Wikipedia]

In other words, Object serialization is the process of saving an object’s state to a sequence of bytes, as well as the process of rebuilding those bytes into a live object at some future time.

The object is serialized to a stream, which carries not just the data, but information about the object’s type, such as its version, culture, and assembly name. From that stream, it can be stored in a database, a file, or memory.

It lets you take an object or group of objects, put them on a disk or send them through a wire or wireless transport mechanism, then later, perhaps on another computer, reverse the process: resurrect the original object(s). The basic mechanisms are to flatten object(s) into a one-dimensional stream of bits, and to turn that stream of bits back into the original object(s).

Data serialization formats:

These are various ways to convert complex objects to sequences of bits. In .NET, BinaryFormatter  and SoapFormatter are prominently used. You can define your own format too. Some other widely used data serialization formats are JSON, XML-RPC, BSON, YAML etc. Each format is having its encoding and decoding rules.

For more details:

Why it named as Serialization:

Serialization is all about converting objects to raw data. Then how it lends itself towards anything that is related to the term “serial”?

Serialization transforms data in memory with data structures and pointers into a series of bytes designed to be saved on a sequential media, such as a hard disk or transferred through something like a serial connection.

It’s probably from networking and communications, where it is necessary to convert data into a serial stream of ones and zeros. The fact that data is sent to disk or over a network as a “stream” is almost certainly the origin of this term.

Another way to think of it, however, is like this: The state of a program is spread all over memory, with pointers/links pointing all over the place. You have arrays, lists, trees, call stacks, heaps of allocated memory, etc., in no particular order. When you want to save some state, you cannot use much of the information in your program. For example, any pointer values or stack offsets (whether used directly or used internally by the language runtime, etc.) will likely not be valid the next time your program runs because the heap will have been used to allocate slightly different series of memory blocks. Saving these pointer values would be useless. To save some state, you have to “put your affairs in order” such that the information being saved is only that part that will be relevant later on.

Uses of Serialization: 

Serialization allows the developer to save the state of an object and recreate it as needed, providing storage of objects as well as data exchange. Through serialization, a developer can perform actions like:

  1. Sending the object to a remote application by means of a Web Service
  2. Passing an object from one domain to another
  3. passing an object through a firewall as an XML string
  4. Maintaining security or user-specific information across applications
  1. Passing an object from on application to another
  1. Storing user preferences in an object
  2. Modification of XML documents without using the DOM

Are methods also serialized along with the data members?

No. Method bodies do not hold any information on the state of an object, so they are not needed in order to save or restore the state.

Useful links on Serialization:

BDotNet Event 07 July, 2012: My Second Presentation on C# 5

Today I presented on “C# 5: Deep Drive into Asynchronous Programming” in BDotnet UG Meeting. It was a great learning and sharing opportunity. Thanks for the core BDotNet team for providing great support and motivating me towards “Continuous Learning and Sharing”…as Vinod used to remind us again and again.

There were following highlights in today’s BDotNet UG Event:

Expert Tip: How to make powerful presentation
by Vinod Kumar M

While organizing the topics for a presentation, think in this way:

  1. Consider a junior most guy: what you can explain him better……A flower
  2. For senior most guy: How to enhance or refresh his knowledge……Another flower
  3. What more topics you want to put in presentation……More flowers.
  4. Make a nice story with smooth flow of topics….Like putting flowers together in a garland.
This was the Tip # 1 to make a great presentation. We can expect more such tip from him in incoming UG sessions.

Session 1: ASP.NET HTML5 Compatibility 
by Chaitra Nagaraj

She explained about the various new features of HTML5 and how we can incorporate these features in a ASP.NET application. She also explained regarding the compatibility with different browsers and versions of IE, while such development. At the end of session she shared the link  to explore more about HTML5.

Session 2: C# 5: Deep Drive into Asynchronous Programming 
by Praveen Prajapati

In this session, I covered the following topics:

  • What is asynchrony
  • Related Terms and Need of Asynchrony
  • Why TPL: The Free Lunch is Over
  • C# 4: Task Parallel Library
  • C# 4: TPL Demo
  • C# 5: Asynchronous Programming
  • C# 5: Behind the Scene
  • C# 5: Async Demo

The slide deck is shared at
You can get the code too from

Thanks to all BDotNetters for making today’s UG Meet wonderful. My special thanks goes to Vinod, Pinal, Lohith and Manas for their support during the session.

Facebook Link of this UG Meet:

Welcome to Visual Studio 2012

The Release Candidates of Visual Studio 11, now officially named Visual Studio 2012, are available to all developers (including MSDN subscribers). In addition to a new name, and a new purple logo, Microsoft is reintroducing a customizable setup process that allows developers to bypass installation of select Visual Studio components.


For more information follow:

BDotNet UG Meeting 28 April 2012: Windows Phone Development

We had two superb sessions on Windows Phone Development by Atley Hunter in BDotNet UG Meet today.

The Speaker:

Atley Hunter is a passionate phone application developer with over 15 years’ experience. He is Microsoft MVP Windows Phone Development and Telerik insider. His other coordinates are as follows:
Code Creators:
Blog @
LinkedIn @

Session 1: My Mic Sounds Nice – Using Multimedia in Your Windows Phone App

The session started with Beginning on Phone Development and discussed basic philosophy of basic application development. He started with: Apps may be very simple but useful. Then we had code walkthrough on: Adding sounds to XNA Games, Controlling sounds playback, Creating Looping Sounds etc. He used Visual Studio 2010 | XNA GameStudio 4.0 | Winows Phone Game 4.0 template for first code walkthrough Adding sounds to XNA Games and shown us how to all audio to games.

He gave many tips regarding Windows Phone Apps development as one of the advices was: “Make copy of own background image”: use it in all applications that you develop so it will serve as your identity.

He gave an overview of SyncFusion MetroStudio 1( also to design unique Metro icons.

Session 2: Being Ready for Awesome: Using Live Tiles, Background Tasks and Services

In this session he discussed about Windows Phone 7.5 Application Lifecycle, How to balance between Health and User Experience of an application and what points to take care of in these regard. Then he discussed about “Background Transfer Service ” and “Background Agent functionality” etc.

Both sessions were very informative and very helpful for developers who are on apps development. After the sessions we had a quiz (some questions for session itself) and winners got goodies from Telerik and Pluralsight.

Many many thanks to Atley Hunter to sharing practical knowledge and best practices with us. Thanks to Vinod Kumar M and Lohith Goudagere Nagaraj for arranging this wonderful event. Thanks to all BDotNet memebrs who joined and made the event successful.

Thanks for reading! Have a nice time!