Geeks With Blogs
The code samples in Microsoft All-In-One Code Framework are updated on 2011-1-23.
You can download individual code samples or browse code samples grouped by technology inthe updated code sample index.
If it’s the first time that you hear about Microsoft All-In-One Code Framework, please read this Microsoft News Center article, or watch the introduction video on YouTube, or read the introduction on our homepage
New Azure Code code samples
CSAzureBingMaps and VBAzureBingMaps
The AzureBingMaps sample is an application sample demonstrating how to design and build a solution that combines multiple cloud services and client devices. It uses the following cloud services:
  • Windows Azure
  • SQL Azure
  • Windows Azure AppFabric
  • Windows Live Messenger Connect
  • Bing Maps
It also contains client applications for the following devices:
  • A HTML client for web browsers
  • A Silverlight client for Windows PCs and Macs
  • A Silverlight client for Windows Phone devices
The sample also demonstrates a lot of technologies, such as Entity Framework, WCF, jQuery, and so on.
You can find a series of blog posts describing it on A live demonstration of the HTML client can be found at A live demonstration of the Silverlight client can be found at Note we don’t promise we’ll always keep the live demonstrations alive.
Here is a screenshot of the sample application:
New Windows General and IE code samples 
CppRegisterHotkey, CSRegisterHotkey and VBRegisterHotkey
The sample demonstrates how to register and unregister a hotkey (e.g. Alt, Control + X) for the current application. When the hotkey is hit, your application will receive a special message, and you can, for example, set your application window to the front.
CSDetectWindowsSessionState and VBDetectWindowsSessionState
The sample demonstrates how to detect the Windows session state. We observe that many customers ask how to detect session lock and unlock events in applications. You will get the answer in this code sample.  Here is a screenshot of the code sample:
CSFTPDownload and VBFTPDownload 
MSDN contains some code samples about how to download one file at a time from an FTP server. However in MSDN forums, many customers ask how to download multiple files or entire directory structure (files and sub-directories etc.) from an FTP server.  This code sample will answer it. The code sample demonstrates downloading one or multiple files from FTP,  and listing files. It's basically a small FTP client sample application.

CSFTPUpload and VBFTPUpload
This code sample demos uploading files to FTP and deleting files on FTP. It is a supplement to the above CS/VBFTPDownload code sample.
CSMultiThreadedWebDownloader and VBMultiThreadedWebDownloader
The sample demonstrates how to download file using multiple threads.
1. To pause and resume a download, or download a file using multi-threads, the server must support "Accept-Ranges" header, so that we can add range to the webrequset to download a specified block of the file.
2. If you are trying to download a single file using multiple threads/ multiple HttpWebRequest’s, multiple requests (each asking for a different range) will all be pipelined over a single connection (not necessarily all). You have to take into consideration as to how many threads you are spinning, and how many max Connections you have set for the ServicePointManager. By default, ServicePointManager has a default of 2 max connections for console applications, so only 2 requests can be active at a time and will be downloading 2 parts of the large file. So yes, your approach will speed up the download, but you also need to take into account the maximum number of connections. If you increase the number of available connections,you will get a better download rate. But, do not increase it to a very large value, otherwise you will end up spiking the CPU due to the overhead of creating multiple connections simultaneously. Try to limit the max Conn number = 12 * # CPU which uses.
CSTabbedWebBrowser and VBTabbedWebBrowser
The sample demonstrates how to create a tabbed WebBrowser.  This is also frequently asked in MSDN forums.  Here is a screenshot of the code sample.
CSWebBrowserAutomation and VBWebBrowserAutomation
The sample demonstrates how to create a WebBrowser which supplies following features
  • Manipulate the html elements and login a website automatically.
  • Block specified sites.
CSCustomCodeAnalysisRule and VBCustomCodeAnalysisRule
The sample demonstrates how to create, deploy and run custom Code Analysis rules.


New Windows Forms code samples


CSRichTextBoxSyntaxHighlighting and VBRichTextBoxSyntaxHighlighting
The sample demonstrates how to format XML and highlight the elements in a RichTextBox control.

New ASP.NET code samples
CSASPNETEmailAddressValidator and VBASPNETEmailAddressValidator
C# version:
VB version:

When we develop a register form, we often want the user to submit their Email address, so we can send some information to them. The easiest way is to use a regular expression to validate the format of the address. For example,

We can use Regex class to validate the format of the input string. But the problem with this way is that we can’t check whether the Email address is reachable. It is possible that the user would not input his own address or someone has a typo. So the key issue here is how to check whether the Email address is available.  AS far as I know, there are two ways that we can try. The first one is to analyze the Email address to get the MX records of that mail server and send some requests to that server and check the response code. It looks a good idea and the validation is fast, but in these years, Internet is full of junk mails, we call these mails as Spam. And now almost all the mail servers have been updated to support Anti-Spam. And that’s the principle of the first way just similar with the spam robot. So we have to give up this way because the request message would act as a spam message and be rejected by the mail server. Its return code would never be accurate. So the second way, as the code sample demos, is to send a confirmation mail and let the user click a special link in that mail to complete the validation. The only shortage is that we need to wait for the user to open his received mail and could not validate the address at once. Anyway, it is a safe and possible workaround.
CSASPNETSerializeJsonString and VBASPNETSerializeJsonString
When working with JavaScript and ASP.NET together we will no doubt find ourselves having to return objects from the server side to the client side. One common method of doing is to return XML which represents the object we want to return. However, a much easier option is to return JSON, JSON is another format of expressing data, just like XML, it is simpler and tiny than XML. Using a framework such as jQuery we can simply retrieve the JSON and have concrete JavaScript object ready for manipulation.
This sample is using .NET System.Web.Script.Serialization namespace's JSON serializer component to perform .NET --- JSON data convertion. Here is running jQuery AutoComplete to perform the AJAX request. On the sample, when user enters a character like ‘m’, the AutoComplete list will display automatically.  Once choosing one item in list, the related information of this item will show on the dashboard.

Posted on Tuesday, January 25, 2011 11:02 PM | Back to top

Comments on this post: Microsoft All-In-One Code Framework Code Sample Update in January 2011

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Geekswithblogs | Powered by: