Dixin's Blog
Microsoft Most Valuable Professional (CodingOnWheels.com) & Photographer (PicturesOnWheels.com). Code examples: GitHub.com/Dixin/Blog.
-
Attach SQL Server 2000 database to SQL Server 2014
In the MSDN introduction for LINQ to SQL, the Northwind sample database is used. It is a 15 years old database for SQL Server 2000. After downloading the database files, it cannot be attached to the latest SQL Server 2014 or 2016. trying to do so results an error:
-
Understanding C# async / await (3) Runtime Context
Understanding C# async / await:
- Understanding C# async / await (1) Compilation
- Understanding C# async / await (2) Awaitable-Awaiter Pattern
- Understanding C# async / await (3) Runtime Context
Part 1 explained the compilation of await:
- In a async method with await keyword, all the code are compiled into a state machine’s MoveNext() method.
- When this async method is called, the state machine is started. Along with the change of the state, MoveNext() will be called in a callback-like style.
-
Understanding C# async / await (2) The Awaitable-Awaiter Pattern
Understanding C# async / await:
- Understanding C# async / await (1) Compilation
- Understanding C# async / await (2) Awaitable-Awaiter Pattern
- Understanding C# async / await (3) Runtime Context
What is awaitable
Part 1 shows that any Task is awaitable. Actually there are other awaitable types. Here is an example:
Task<int> task = new Task<int>(() => 0); int result = await task.ConfigureAwait(false); // Returns a ConfiguredTaskAwaitable<TResult>.
The returned ConfiguredTaskAwaitable<TResult> struct is awaitable. And it is not Task at all:
-
Understanding C# async / await (1) Compilation
Understanding C# async / await:
- Understanding C# async / await (1) Compilation
- Understanding C# async / await (2) Awaitable-Awaiter Pattern
- Understanding C# async / await (3) Runtime Context
Now the async / await keywords are in C#. Just like the async and ! in F#, this new C# feature provides great convenience. There are many nice documents talking about how to use async / await in specific scenarios, like using async methods in ASP.NET 4.5 and in ASP.NET MVC 4, etc. This article will look at the real code working behind the syntax sugar.
As MSDN stated:
The async modifier indicates that the method, lambda expression, or anonymous method that it modifies is asynchronous.
Also since lambda expression / anonymous method will be compiled to normal method, this article will focus on normal async method.
-
Recover Outlook 2010 from crash
Today my Outlook 2010 crashed while I am writing an email. When I restart I got this error:
-
My new car at Microsoft Building 35
I got this from the local dealership. These photos were taken at Microsoft Building 35:
-
Understanding LINQ to SQL (11) Performance
LINQ to SQL has a lot of great features like
- strong typing
- query compilation
- deferred execution
- declarative paradigm
etc., which are very productive. Of course, these cannot be free, and one price is the performance.
-
A DirectoryCatalog class for Silverlight MEF (Managed Extensibility Framework)
In the MEF (Managed Extension Framework) for .NET, there are useful ComposablePartCatalog implementations in System.ComponentModel.Composition.dll, like:
- System.ComponentModel.Composition.Hosting.AggregateCatalog
- System.ComponentModel.Composition.Hosting.AssemblyCatalog
- System.ComponentModel.Composition.Hosting.DirectoryCatalog
- System.ComponentModel.Composition.Hosting.TypeCatalog
While in Silverlight, there is a extra System.ComponentModel.Composition.Hosting.DeploymentCatalog. As a wrapper of AssemblyCatalog, it can load all assemblies in a XAP file in the web server side. Unfortunately, in silverlight there is no DirectoryCatalog to load a folder.
-
Microsoft Chinese Spring Festival Celebration (2)
-
Microsoft Chinese Spring Festival Celebration (1)
Last night there was a big party in Redmond: Microsoft Spring Festival Celebration. It is organized by Chime (an employee network group in Microsoft), and it is also the biggest Chinese new year celebration in Seattle area. Thousands of people attended the party, including Steve Ballmer. I also brought my Nikon D700 there.
-
The Humor of Silverlight
-
Arrival to Redmond
In this year, I was rewarded as an MVP on C# of Year 2010; at the same time, 3 different groups of Microsoft offered me 3 SDE II positions, and I made my choice. Now, with the help of Microsoft, I just relocated from China to Redmond.
2 years ago, when I left Redmond, I decided that I’ll be back. Now everything just looks the same as 2 years ago. What a familiar place!
-
Microsoft Most Valuable Professional Kit Unboxing
I am very happy to receive the Microsoft Most Valuable Professional Kit:
-
Ellipses (…) In UI Command Text
Some times, command text is followed by ellipsis (…) or not:
For years, many developers told me that ellipses mean a new window or dialog will pop up. For example, here:
- Clicking New / Save / Exit will not pop up new window or dialog;
- Clicking Open… / Save As… / Page Setup… / Print… will pop up new window or dialog.
But this is not correct. Take a look at About Notepad.
-
A Snapshot Of ASP.NET Homepage
First time to appear on www.asp.net homepage as headline!
-
A ToDynamic() Extension Method For Fluent Reflection
Recently I needed to demonstrate some code with reflection, but I felt it inconvenient and tedious. To simplify the reflection coding, I created a ToDynamic() extension method. The source code can be downloaded from here.
-
Back From Microsoft Web Camps Beijing
I am just back from Microsoft Web Camps, where Web developers in Beijing had a good time for 2 days with 2 fantastic speakers, Scott Hanselman and James Senior.
On day 1, Scott and James talked about Web Platform Installer, ASP.NET core runtime, ASP.NET MVC, Entity Framework, Visual Studio 2010, … They were humorous and smart, and everyone was excited!
-
Anti-Forgery Request Recipes For ASP.NET MVC And AJAX
This post discusses solutions for anti-forgery request scenarios in ASP.NET MVC and AJAX:
- How to enable validation on controller, instead of on each action;
- How to specify non-constant token salt in runtime;
- How to work with the server side validation in AJAX scenarios.
-
Understanding LINQ to SQL (10) Implementing LINQ to SQL Provider
So far LINQ to SQL data CRUD (Creating / Retrieving / Updating / Deleting) has been explained. This post takes a deeper look at the internal implementation of LINQ to SQL query.
-
Understanding LINQ to SQL (9) Concurrent Conflict
Conflicts are very common when concurrently accessing the same data.
Conflicts in concurrent data access
The following code demonstrates the concurrent conflict scenario: