Rockford Lhotka on Windows 8, and WinRT

WinRT API is supported by the following technologies: WinRT .NET, WinRT HTML 5, and WinRT C++


I expect this to be the most widely used technology stack for building WinRT applications. The .NET available to WinRT applications is best thought of as being like .NET on the Windows Phone. It is basically the Silverlight subset of .NET, plus a bunch of WinRT-specific features and capabilities. The differences between Silverlight and WinRT are a bit more dramatic than with WP7, but the analogy remains quite accurate.

The XAML is very close to Silverlight and WPF, and the types of code you can write using C# and VB are very comparable to what you can write today using Silverlight.

Please note that using Silverlight today provides the easiest transition to WinRT in the future. Not seamless or trivial, but practical. In addiiton, WPF can enable a WinRT transition too – especially if you limit your use of WPF and .NET to the Silverlight subset of behaviors and features.


Microsoft has made much of the HTML 5 technology stack for building WinRT applications. In no way are we talking about web sites, web pages, or web applications here. This is smart client development done using technologies that were previously web-focused.

For a .NET developer, the technologies map like this:
HTML instead of XAML
JavaScript instead of C#
WinJS instead of the .NET BCL

In my conversations with traditional web developers, it is a brain-bending moment when I point out that there is no web server involved, and so no server-side code at all here. All the stuff that is done in ASP.NET or PHP is now done in JavaScript. From an architecture, design, and application functionality perspective, a WinRT HTML 5 app is almost, but not completely, unlike a web app.

On the positive side, if a web developer can learn and embrace the smart client architectural model, their skills with HTML, CSS, and JavaScript will carry over to this new platform. Some HTML and CSS assets, and perhaps some js assets, will carry from web development into this type of smart client development as well.

WinRT C++

Finally, C++ remains relevant on WinRT as well. This should come as no surprise, given that the Windows OS developers primarily use C++, and there’ll hopefully be games and other applications that are traditionally created using this technology.

I also suspect that Objective C apps will port to WinRT more directly through C++ than with C# or js, and (at least for my part) I hope that some of the existing iPad/iPhone apps quickly make their way onto WinRT so I can enjoy them.

LINQ to SharePoint 2010

The LINQ to SharePoint Provider is defined in the Microsoft.SharePoint.Linq namespace. It translates LINQ queries into Collaborative Application Markup Language (CAML) queries. It is no longer necessary for developers to know how to write CAML queries. LINQ queries can be used in server code. To query from a client application, use SharePoint’s support for ADO.NET Data Services.

The gateway class for the LINQ to SharePoint provider is Microsoft.SharePoint.Linq.DataContext which represents the data of a SharePoint Foundation Web site.

It is parallel in use and function to the System.Data.Linq.DataContext class in the LINQ to SQL provider. Just as the latter class has a GetTable method that returns a Table(Of TEntity) object that implements System.Linq.IQueryable(Of T), the Microsoft.SharePoint.Linq.DataContext class has a GetList(Of T) method that returns an EntityList(Of TEntity) class that implements System.Linq.IQueryable(Of T). It is objects of type EntityList(Of TEntity) that are queried.

The following is an example of the use of LINQ to query SharePoint Foundation.

Richard Campbell on Windows 8, and C#

The Best of Build with Richard Campbell

On October 4, 2011, Richard Campbell presented in BCIT the highlights of this year’s Windows BUILD conference, as well as added a few of his own insights about the direction of Windows and Microsoft.

The first and most apparent change in Windows 8 is the user interface. Richard showed Windows 8 on the new Samsung tablet, and demonstrated its usability. In Windows 8, everything is considered to be an application, including the traditional desktop. The main screen is similar to a mobile device; it displays icons of the installed applications. The desktop is one of these applications, and by clicking on the Start Menu the user is taken back to the main screen. This main screen is Windows Metro, a new design language that features a simpler and cleaner user interface. Microsoft is pushing Metro as the new way of designing their products, which will rely on WinRT, or Windows Runtime. WinRT is the new programming model that simplifies the interfacing between languages and platforms, consisting of services.

Everything that runs in Windows today will be supported in Windows 8. Silverlight is not going to be phased out, but Richard speculates that it will not go past Silverlight 6. XAML, HTML 5, and CSS 3 will be significant for providing the user interface, and Javascript, C++, C#, and .NET 4.5 will be support the model control. The stack will be the same, but Windows 8 is focusing on separating the CLR (Common Language Runtime) and the different programming languages.

Windows is also introducing an “App Store”, for both desktop applications and mobile applications. Unlike the Android store, these App Store will be curated, and Microsoft will be just as responsible as the developers for any bad or malicious apps. The Internet Explorer 10 app is completely chromeless and does not support plug-ins. However, running Internet Explorer 10 on the desktop will allow plug-ins, and will feel like IE does now with the traditional chrome.

Richard also talked about the popularity of Windows 8. He explained that because many companies didn’t switch to Vista, they waited until Windows 7 to be released. Now that these companies are finally set up with Windows 7, they won’t want to switch again once Windows 8 comes out, and instead wait for Windows 9. Therefore, Windows 8 is directed at the consumer, and Windows 9 will be directed at enterprises.

Binary Serialization

Binary serialization allows data to be re-contsructed automatically when writing it to the output stream. Here, the necessary information that is required to create an exact binary copy of the object is saved onto the storage media. Binary serialization preserves the entire object state, where XML serialization only saves some of the object data.  Another advantage binary serialization has over XML serialization is that it can handle graphs with multiple references to the same object. XML serialization turns each reference into a reference to a unique object. lastly, binary serialization  can serialize the read-only properties.

An example below shows how binary serialization can be implemented in C#:

public void BinarySerialize(string filename, Book myBook)


FileStream fileStreamObject;

fileStreamObject = new FileStream(filename, FileMode.Create);

BinaryFormatter binaryFormatter = new BinaryFormatter();

binaryFormatter.Serialize(fileStreamObject, myBook);



An example below shows how to implement binary deserialization:

public static object BinaryDeserialize(string filename)


FileStream fileStreamObject;

fileStreamObject = new FileStream(filename, FileMode.Open);

BinaryFormatter binaryFormatter = new BinaryFormatter();

return (binaryFormatter.Deserialize(fileStreamObject));



A major advantage of using Binary Serialization is that the object can be de-serialized from the same data you serialized it to in the managed environment. Another advantage is its enhanced performance, as it provides support for complex objects, read-only properties, and circular references, although not easily portable to another platform.

Introduction to Serialization


Serialization is a way changing objects into a compatible format to stream across process boundaries and machines. This type of data makes it easy to transmit over a network or into a persistent storage location, like a file, database, or ASP.NET cache. The serialized data can be read by both sending and receiving machines or processes, and creates a strong form of communication that is cross-platform-compatible. Once the stream has reached the other process, it is deserialized and the same object is reconstructed to its original format.

In .NET, serialization can be done by .NET Remoting, implementing web services or WCF services to transmit data between a server and a client.

Serialization is provided by the System.Runtime.Serialization namespace and its Iformatter interface. IFormatter contains the methods called Serialize and De-serialize that save and load data to and from a stream. Essentially, all that is needed is a stream and a formatter, where the stream acts as a container for the serialized object, and the formatter is used to serialize these objects onto the stream.

Besides passing objects from one application or domain to another, some practical advantages of serialization are being able to modify XML documents without using the Document Object Model (DOM), and these XML files can pass through a firewall.

Some disadvantages however is the CPU and IO resource consumption involved with serializing and deserializing objects. Serialization is slow and the latency when transmitting the data over the network should be taken to the consideration. As well, XML serialization is insecure as it works on public members and public classes. Private or internal classes are not supported, allowing the class to be accessed by anyone.

To serialize a class, the Serializable attribute must be declared, and all of its members become serializable, except if they contain the NonSerialized attribute attribute which just ignores them. Private and public members of a class are always serialized by default, and the Serialization attribute is only used for the binary serialization.

An example of a simple class might be:
public class Book

public string Author;
public string Title;

The Serializable attribute is specified at the beginning of the class, in square brackets above the class declaration. Even if the ISerializable interface has not been implemented inside the class, it is a good practice to apply the Serializable attribute.

If this attribute was not declared in the beginning of the class, then when we try to serialize an object the CLR throws a SerializationException.

Copyright © All Rights Reserved - C# Learners