2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies
The 2007 Microsoft Office system Primary Interop Assemblies (PIA) redistributable is a Microsoft Windows Installer package that contains the Primary Interop Assemblies for 2007 Microsoft Office system products.
Read more: MS Download
A Plethora Parallel Programming PDF’s - 12 Parallel Programming with the .NET Framework 4 articles for download
Posted by
jasper22
at
10:49
|
A set of articles that provide information on parallel programming with the .NET Framework 4.
OptimizingUsingConcurrencyVisualizer.pdf 2.1MB
ParallelProgramsinNET4_CodingGuidelines.pdf 964KB
ParentChildTPLTasksRelationship.pdf 787KB
PerformanceCharacteristicsOfSyncPrimitives.pdf 800KB
PerformanceCharacteristicsOfThreadSafeCollection.pdf 682KB
PLINQOrderingModel.pdf 1.0MB
TPLOptionsTour.pdf 1.1MB
Using Net4ToAchieveDataParallelism.pdf 925KB
UsingCancellationinNET4.pdf 1.1MB
UsingPLINQinOfficeAddins.pdf 761KB
WhenToUseParallelForEachOrPLINQ.pdf 527KB
WorkflowAndParallelExtensionsinNET4.pdf 648KB
Read more: Greg's Cool [Insert Clever Name] of the Day
Convert Flash(R) to Silverlight(R)
Posted by
jasper22
at
09:42
|

SilverX products are aimed to help to migrate existing Flash movies into Silverlight platform. Using SilverX and SilverX Expression you can easily
Convert your SWF file to ready-to-run Silverlight application (or Silverlight XAP file)
Convert or import your Flash file into Silverlight, Windows Presentation Foundation (WPF) or Silverlight for Windows phone project
Extract vector graphics and animations in XAML format
Extract raster images in PNG or JPEG format
Extract sounds in MP3 or WMA format
The results of Flash to Silverlight conversion then can be used in Microsoft Expression Blend,
Microsoft Visual Studio or any other Silverlight/WPF authoring environment.
Read more: SilverX
Wireless LAN Security and Penetration Testing Megaprimer
Posted by
jasper22
at
09:23
|
This video series will take you through a journey in wireless LAN (in)security and penetration testing. We will start from the very basics of how WLANs work, graduate to packet sniffing and injection attacks, move on to audit infrastructure vulnerabilities, learn to break into WLAN clients and finally look at advanced hybrid attacks involving wireless and applications.
Read more: SecurityTube
Drop Shadow / Glow Effect using XAML
Posted by
jasper22
at
09:21
|
As most of know Silverlight has built in effects, however these effects can be pretty memory intensive. One solution would be is to use an image for the shadow, however if you’re planning for the object casting the shadow or glow to dynamically scale the image will either pixelate or not scale. The other solution is to create your drop shadows using rectangles in XAML.
Here I illustrate the memory usage of a drop shadow effect, a drop shadow built in XAML, and no drop shadow at all on a Dialog Window in Silverlight.
We can see that no drop shadow is the winner in terms of performance but a drop shadow built with XAML is a very close second using only an extra 12kb. The Built in effect in Silverlight uses over 3,000 kb more!
So how do you create a drop shadow effect in XAML? It’s actually very easy. Just create an offset grid with negative margins (this will be the distance from you object the drop shadow will cast) and add a series of Rectangles with varying corner radiuses, margins, and opacity.
<Grid Margin="-2,-2,-6,-6">
<Rectangle Stroke="Black" Margin="5" RadiusX="7" RadiusY="7" Opacity="0.3"/>
<Rectangle Stroke="Black" Margin="4" RadiusX="8" RadiusY="8" Opacity="0.25"/>
<Rectangle Stroke="Black" Margin="3" RadiusX="9" RadiusY="9" Opacity="0.2"/>
<Rectangle Stroke="Black" Margin="2" RadiusX="10" RadiusY="10" Opacity="0.15"/>
<Rectangle Stroke="Black" Margin="1" RadiusX="11" RadiusY="11" Opacity="0.1"/>
Read more: Infragistics
Switching Between HTTP and HTTPS Like A Bigshot Hotshot
Posted by
jasper22
at
09:12
|
Introduction
When we, as developers, encounter the same coding scenario time and time again, we naturally tend to encapsulate the coding logic and reuse it in an effort to save time and minimize maintenance.
Recently, while developing a website called Bigshot Hotshot, I reevaluated the need to switch between secure (HTTPS/SSL) and non-secure (HTTP/non-SSL) pages. I noticed that while coding, we do not, in most cases, think about using SSL. One reason is that (at the time of this writing) the ASP.NET Development Server does not support SSL. To test SSL pages, we need to add our application/website to IIS and configure it accordingly. Another problem I wanted to solve was how to hint to IIS that certain pages should always use HTTPS while others should always use HTTP. To complicate things even further, I wanted to take SEO (search engine optimization) into account as well so that redirecting between secure and non-secure pages does not have a negative impact on the website's SEO.
This article presents one way of solving the aforementioned issues. For brevity, we will abbreviate the phrase: switch(ing) between HTTP and HTTPS to HTTP <=> HTTPS.
Background Research
Solution/Proposal 1
While researching potential solutions for the issue of HTTP <=> HTTPS, I came across an article by Matt Sollars: Switching Between HTTP and HTTPS Automatically: Version 2. It is a well-written solution to the above problem. I like how you can enforce entire directories to use SSL, as well as individual pages. I also like the web.config based approach to specify which files should use SSL. On the other hand, the solution is more complicated than what I needed. In addition, HTTP <=> HTTPS by calling Response.Redirect([path], true), and ending the Response is not very SEO friendly.
Solution/Proposal 2
Another solution to HTTP <=> HTTPS I came across was by Yohan B: RequireSSL Attribute for ASP.NET. I like the Attribute based approach of specifying that certain pages are required to use SSL. I also like the use of the #if DEBUG directive to tell the compiler not to HTTP <=> HTTPS while running in Debug mode (since ASP.NET Development Server does not support SSL anyway). What I am not quite fond of, however, is the use of a base Page that all other Pages inherit from to call the Validate() method and control HTTP <=> HTTPS. Also, just like in the above article, HTTP <=> HTTPS by calling Response.Redirect([path], true), and ending the Response is not very SEO friendly.
Our Strategy
What we will be looking at in the next section is another way to HTTP <=> HTTPS. We will use Attributes to mark which Pages require SSL, and we will implement a custom HTTP module responsible for intercepting requests to our ASPX pages and for HTTP <=> HTTPS when necessary. We will also examine how to do this in an SEO friendly manner.
The Code
First off, we need to define an Attribute so we can decorate the Pages that require SSL with that Attribute. Let's define an Attribute called RequireSSL:
/// <summary>
/// Attribute decorated on classes that use SSL
/// <summary>
[AttributeUsage(AttributeTargets.Class)]
sealed public class RequireSSL : Attribute
{
}
In our example project, the login.aspx and signup.aspx pages require SSL. We will mark them accordingly (notice the RequireSSL attribute):
/// <summary>
/// The Login Page
/// </summary>
[RequireSSL]
public partial class login : System.Web.UI.Page
{
...
}
/// <summary>
/// The SignUp Page
/// </summary>
[RequireSSL]
public partial class signup : System.Web.UI.Page
{
...
}
Next, we will implement our custom HTTP module. It will be configured so that the code for HTTP <=> HTTPS only runs when compiled in Release mode:
/// <summary>
/// HttpModule for switching between HTTP and HTTPS (HTTP <=> HTTPS)
/// </summary>
public class RequireSSLModule : IHttpModule
{
public void Init(HttpApplication context)
{
// only attach the event if the build is not set to Debug
#if !DEBUG
// The PreRequestHandlerExecute event occurs just
// before ASP.NET begins executing a handler such as a Page
// In here we can acquire a reference
// to the currently executing ASPX Page
context.PreRequestHandlerExecute +=
new EventHandler(OnPreRequestHandlerExecute);
#endif
}
...
}
Let's take a closer look at the PreRequestHandlerExecute event.
/// <summary>
/// Handle switching between HTTP and HTTPS.
/// It only switches the scheme when necessary.
/// Note: By scheme we mean HTTP scheme or HTTPS scheme.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void OnPreRequestHandlerExecute(object sender, EventArgs e)
{
// obtain a reference to the ASPX Page
System.Web.UI.Page Page =
HttpContext.Current.Handler as System.Web.UI.Page;
Read more: Codeproject
The Basics of Task Parallelism via C#
Posted by
jasper22
at
09:09
|
Preface
The trend towards going parallel means that .NET Framework developers should learn about the Task Parallel Library (TPL). But in general terms, data parallelism uses the input data to some operation as the means to partition into smaller pieces. The data is divvied up among the available hardware processors in order to achieve parallelism. It is then often followed by replicating and executing some independent operation across these partitions. It is also typically the same operation that is applied concurrently to the elements in the dataset.
Task parallelism takes the fact that the program is already decomposed into individual parts – statements, methods, and so on – that can be run in parallel. More to the point, task parallelism views a problem as a stream of instructions that can be broken into sequences called tasks that can execute simultaneously. For the computation to be efficient, the operations that make up the task should be largely independent of the operations taking place inside other tasks. The data-decomposition view focuses on the data required by the tasks and how it can be decomposed into distinct chunks. The computation associated with the data chunks will only be efficient if the data chunks can be operated upon relatively independently. While these two are obviously inter-dependent when deciding to go parallel, they can best be learned if both views are separated. A powerful reference about Tasks re Compute-bound asynchronous operations is Jeffrey Richter’s book, “CLR via C#, 3rd Edition.” It is a good read.
In this brief article we will focus on some of the characteristics of the System.Threading.Tasks Task object. To perform a simple Task, create a new instance of the Task class, passing in a System.Action delegate that represents the workload that you want performed as a constructor argument. You can explicitly create the Action delegate so that it refers to a named method, use an anonymous function, or use a lambda function. Once you have created an instance of Task, call the Start() method, and your Task is then passed to the task scheduler, which is responsible for assigning threads to perform the work. Here is example code:
using System;
using System.Threading.Tasks;
public class Program {
public static void Main() {
// use an Action delegate and named method
Task task1 = new Task(new Action(printMessage));
// use an anonymous delegate
Task task2 = new Task(delegate { printMessage() });
// use a lambda expression and a named method
Task task3 = new Task(() => printMessage());
// use a lambda expression and an anonymous method
Task task4 = new Task(() => { printMessage() });
task1.Start();
task2.Start();
task3.Start();
task4.Start();
Console.WriteLine("Main method complete. Press <enter> to finish.");
Console.ReadLine();
}
private static void printMessage() {
Console.WriteLine("Hello, world!");
}
}
To get the result from a task, create instances of Task, where T is the data type of the result that will be produced and return an instance of that type in your Task body. To read the result, you call the Result property of the Task you have created. For example, let's say that we have a method called Sum. We can construct a Task object, and we pass for the generic TResult argument the operation's return data type:
using System;
using System.Threading.Tasks;
public class Program {
private static Int32 Sum(Int32 n)
{
Int32 sum = 0;
for (; n > 0; n--)
checked { sum += n; }
return sum;
}
public static void Main() {
Task<int32> t = new Task<int32>(n => Sum((Int32)n), 1000);
t.Start();
t.Wait();
// Get the result (the Result property internally calls Wait)
Console.WriteLine("The sum is: " + t.Result); // An Int32 value
}
}
Produces:
The sum is: 500500
If the compute-bound operation throws an unhandled exception, the exception will be swallowed, stored in a collection, and the thread pool is allowed to return to the thread pool. When the Wait method or the Result property is invoked, these members will throw a System.AggregateException object. You can use CancellationTokenSource to cancel a Task. we must rewrite our Sum method so that it accepts a CancellationToken, after which we can write the code, creating a CancellationTokenSource object.
Read more: Codeproject
Even if you have a lock, you can borrow some lock-free techniques
Posted by
jasper22
at
09:08
|
Even if you prefer to use a lock (after all, they are much easier to program), you can borrow some lock-free techniques. For example, consider this:
CRITICAL_SECTION g_cs;
GORILLADATA g_data;
void PokeGorilla(double intensity)
{
EnterCriticalSection(&g_cs);
DeformGorilla(intensity, &g_data);
Reticulate(&g_data.spline);
int stress = CalculateTension(&g_data.spline);
if (stress < 25) g_data.mood = RELAXED;
else if (stress < 50) g_data.mood = ANNOYED;
else g_data.mood = ANGRY;
DeleteObject(g_data.hbmGorilla);
g_data.hbmGorilla = RenderGorilla(&g_data);
LeaveCriticalSection(&g_cs);
}
There are some concerns here. First of all, there's the lock hierarchy issue: If reticulating a spline takes the geometry lock, that may violate our lock hierarchy.
If the lock g_cs is a hot lock, you may be concerned that all this gorilla stuff will hold the lock for too long. Maybe rendering a gorilla is a slow and complicated operation because it's hard to get the fur just right.
These issues become less onerous if you switch to a lock-free algorithm, but that's an awful lot of work, and it's hard to get right. But maybe you can do just 20% of the work to get 80% of the benefit.
void PokeGorilla(double intensity)
{
// Capture
EnterCriticalSection(&g_cs);
GORILLADATA data = g_data; // typo fixed
LeaveCriticalSection(&g_cs);
// Recalculate based on captured data
DeformGorilla(intensity, &data);
Reticulate(&data.spline);
int stress = CalculateTension(&data.spline);
if (stress < 25) data.mood = RELAXED;
else if (stress < 50) data.mood = ANNOYED;
else data.mood = ANGRY;
data.hbmGorilla = RenderGorilla(&data);
// Commit
EnterCriticalSection(&g_cs);
HBITMAP hbmToDelete = g_data.hbmGorilla;
g_data = data;
LeaveCriticalSection(&g_cs);
DeleteObject(hbmToDelete);
}
Here, we use the capture/try/commit model. We capture the state of the gorilla into a local variable, then perform our update based on that captured state. The spline reticulation takes place without any locks held, which avoids introducing a lock hierarchy violation. And rendering the gorilla is done without any locks held, which avoids introducing a choke point on the lock. After the calculations are done, we then re-enter the lock and commit the changes.
This pattern uses a last-writer-wins model. If another thread pokes the gorilla while we are still calculating the previous gorilla state, we will overwrite that gorilla state when we complete. For some scenarios, that's acceptable. But maybe the gorilla's emotional state needs to be an accumulation of all the times he's ben poked. We want to detect that somebody has poked the gorilla while we were busy calculating so that we can incorporate that new information into the final result.
Read more: The old new thing
Manipulate XML data with XPath and XmlDocument (C#)
Posted by
jasper22
at
09:07
|
Introduction
Based on a section of easy-to-read XML source data, I'll show you how to select and locate XML nodes and navigate through them using XPathNavigator and XPathNodeIterator. I will provide a few straightforward samples about XPath expression with which you could follow without difficulty. In the last part, there is some sample code to update, insert and remove XML nodes.
Some Concepts
XML - Extensible Markup Language, describe data structures in text format and with your own vocabularies, which means it does not use predefined tags and the meaning of these tags are not well understood.
XSL - Extensible Stylesheet Language, is designed for expressing stylesheets for XML documents. XSL is to XML as CSS is to HTML.
XML Transformation - is a user-defined algorithm that transforms a given XML document to another format, such as XML, HTML, XHTML. The algorithm is described by XSL.
XSLT - is designed for use as part of XSL, transforming an XML document into another XML document, or another type of document that is recognized by a browser, like HTML or XHTML. XSLT uses XPath.
XPath - is a set of syntax rules for defining parts of an XML document.
To keep this article simple and clear, I'll break it down into two parts, and put XSL, XSLT to my next article.
Using the code
Here is the source XML data:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd country="USA">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<price>10.90</price>
</cd>
<cd country="UK">
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<price>10.0</price>
</cd>
<cd country="USA">
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<price>9.90</price>
</cd>
</catalog>
If you want to select all of the price elements, here is the code:
using System.Xml;
using System.Xml.XPath;
....
string fileName = "data.xml";
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator nav = doc.CreateNavigator();
// Compile a standard XPath expression
XPathExpression expr;
expr = nav.Compile("/catalog/cd/price");
XPathNodeIterator iterator = nav.Select(expr);
// Iterate on the node set
listBox1.Items.Clear();
try
{
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
listBox1.Items.Add("price: " + nav2.Value);
}
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
In the above code, we used "/catalog/cd/price" to select all the price elements. If you just want to select all the cd elements with price greater than 10.0, you can use "/catalog/cd[price>10.0]". Here are some more examples of XPath expressions:
/catalog selects the root element
/catalog/cd selects all the cd elements of the catalog element
/catalog/cd/price selects all the price elements of all the cd elements of the catalog element
/catalog/cd[price>10.0] selects all the cd elements with price greater than 10.0
starts with a slash(/) represents an absolute path to an element
starts with two slashes(//) selects all elements that satisfy the criteria
//cd selects all cd elements in the document
/catalog/cd/title | /catalog/cd/artist selects all the title and artist elements of the cd elements of catalog
//title | //artist selects all the title and artist elements in the document
/catalog/cd/* selects all the child elements of all cd elements of the catalog element
/catalog/*/price selects all the price elements that are grandchildren of catalog
/*/*/price selects all price elements which have two ancestors
//* selects all elements in the document
/catalog/cd[1] selects the first cd child of catalog
/catalog/cd[last()] selects the last cd child of catalog
/catalog/cd[price] selects all the cd elements that have price
/catalog/cd[price=10.90] selects cd elements with the price of 10.90
/catalog/cd[price=10.90]/price selects all price elements with the price of 10.90
//@country selects all "country" attributes
//cd[@country] selects cd elements which have a "country" attribute
//cd[@*] selects cd elements which have any attribute
//cd[@country='UK'] selects cd elements with "country" attribute equal to 'UK'
Read more: Codeproject
12 Excellent Cloud Computing Operating Systems
Posted by
jasper22
at
09:05
|
Cloud is not just a natural form of smoke. It is also the most hyped term in the IT industry right now. Everyone is talking about cloud and vendors all cloudify their products and service offerings. In the area of operating systems this is also happening and a cloud OS is simply a simplified operating system that runs just a web browser (at least that is one definition of it), providing access to a variety of web-based applications that allow the user to perform many simple tasks without booting a full-scale operating system. Because of its simplicity a cloud OS can boot in just a few seconds. The operating system is designed for Netbooks, Mobile Internet Devices, and PCs that are mainly used to browse the Internet. From a cloud OS the user can quickly boot into the main OS, because it is possible to continue booting the main OS in the background while using a cloud OS (at least this is the goal). 
1. Glide

Glide OS 4.0 is a comprehensive Ad-Free cloud computing solution. Glide is a free suite of rights-based productivity and collaboration applications with 30GBs of storage. Users who want extra storage or would like to add extra users can upgrade to Glide Premium now with 250 GBs for $50.00 a year or 20 cents per GB per year. With a Glide Premium account you can set up and administer up to 25 users. The Glide OS provides automatic file and application compatibility across devices and operating systems. With Glide OS you also get the Glide Sync App which helps you to synchronize your home and work files.
2. Amoeba
3. myGoya
4. Kohive
5. Zimdesk
6. Ghost
Read more: Tripwire magazine
Back to Basics: Delegates, Anonymous Methods and Lambda Expressions
Introduction
Like generics, delegates are one of those features that developers use without really understanding. Initially this wasn’t really a problem since delegates were reserved for fairly specific purposes: implementing callbacks and as the building-block for events (amongst a few other edge cases). However, each version of .NET has seen delegates evolve, first with the introduction of anonymous methods in 2.0 and now with lambda expressions in C# 3.0. With each evolution, delegates have become less of an specific pattern and more of a general purpose tool. In fact, most libraries written specifically for .NET 3.5 are likely to make heavy use of lambda expressions. As always, our concern isn’t just about understanding the code that we use, but also about enriching our own toolset. Seven years ago it wouldn’t have been abnormal to see even a complex system make little (or no) us of delegates (except for using the events of built-in controls). Today, however, even the simplest systems heavily relies on them.
Delegates
The best way to learn about all three framework/language feature is to start from the original and build our way up, seeing what each evolution adds. Delegates have always been pretty simple to understand, but without any good reason to use them, people never really latched on to the concept. It’s always easier to understand something when you can see what problem it solves and how it’s used – and examples of delegates always seem contrived.
Delegates are .NETs version of function pointers – with added type safety. If you aren’t familiar with C or C++ (or another lower level languages) that might not be very helpful. Essentially they let you pass a method into another method as an argument. Although many developers understand the concept in languages such as JavaScript, the strictness of C#/VB.NET makes it a little more confusion. For example, the following JavaScript code is completely valid (and even common):
function executor(functionToExecute)
{
functionToExecute(9000);
}
var doSomething = function(count){alert(“It’s Over ” + count);}
executor(doSomething);
Read more: CodeBetter
Finally, You Can Kiss People Over the Internet [VIDEO]
Posted by
jasper22
at
12:17
|

Tactile communications: it may not sound too exciting, but it’s precisely the field of research that produced a device which lets users “transmit the feeling of a kiss” long-distance.
The Kajimoto Laboratory at the University of Electro-Communications has created a device which consists of a hardware receptacle which is placed into the mouth, and software that remembers the movements of your tongue and sends them to the other connected device, which moves accordingly.
Of course, there’s more to a kiss than just the movement of the tongue, and the folks from Kajimoto plan to recreate them all. “The elements of a kiss include the sense of taste, the manner of breathing, and the moistness of the tongue. If we can recreate all of those I think it will be a really powerful device,” they explain in a video showcasing the device prototype.
Read more: Mashable
הפצת מערכות הפעלה באמצעות הכלים החינמיים של מיקרוסופט
Posted by
jasper22
at
10:26
|
MDT - Microsoft Deployment Toolkit, הינה מערכת של כלי עזר וסקריפטים המאפשרת הפצה של מערכות הפעלה מבית מיקרוסופט. כיום אני בדעה שזו אחת המערכות הטובות שיש בשוק (עבור מערכות הפעלה של מיקרוסופט בלבד) ולמרבה הפליאה היא אף חינמית, אך כמו רומנים רבים אחרים, ההתחלה הייתה קשה, כמו כל פולניה טובה היא לא התמסרה בקלות . כאמור מדובר בערכה חינמית וככזו היא דורשת הרבה יותר התאמות והכנות, מאשר מוצרי מדף מסחריים מקבילים, אבל אל דאגה המערכת מגיעה עם תיעוד ענף. "נאלצתי" לקרוא ולקרוא ובסוף לקרוא עוד קצת, לפני שניגשתי למלאכה, אך לטעמי עבודת ההכנה בתחילת הקשר השתלמה מאוד (פירוט בהמשך)
פתרון חינמי. יתרון שאנו הישראלים אוהבים מאוד . בעוד שפתרונות מסחריים מקבילים עולים כסף רב, פתרון זה ניתן חינם אין כסף, בהסתייגות קלה, אם בוחרים ביישום של הפצה אוטומטית לחלוטין יש צורך להשתמש בבסיס נתונים. SQL כידוע לא ניתן חינם, אך ניתן להשתמש ב-SQL Express או ב-SQL אירגוני ובכך לחסוך גם בעלות זאת.
מערכת פתוחה. כאמור הפתרון מורכב מסט של כלים וסקריפטים ולכן ניתן להתאימו לדרישות האתר ביתר קלות. אפשר להוסיף למערך סקריפטים, אפליקציות, ושינוי הגדרות בהתאם לדרישות הלקוח. מסיבה זו ניתן למצוא תוספים רבים למוצר, ברחבי רשת האינטרנט. המוצר גם זוכה לשדרוגים תכופים של מיקרוסופט עצמה.
הפצה חצי אוטומטית (LTI - Lightwight installation) . הכוונה היא שניתן ליצר מנגנון הפצה שיתשאל , תוך כדאי התהליך, את המשתמש לגבי העדפותיו (באמצעות טפסי הזנת נתונים) כגון שם מחשב, רזולוציית מסך, הגדרות אזור וכ"ו.
Read more: MS Support blog
C# Silverlight WCF: Thread Safe Multiple Async Call Strategy With Final Operation To Join Data.
Posted by
jasper22
at
10:24
|
This article describes one way to handle asynchronous or async calls in .Net 3.5 or .Net 4.0 when using WCF in Silverlight in C#. The goal is to have a final operation wait for all the calls to finish so to combine all the data gathered, all in a thread safe way. A secondary goal is to minimize the consumer code required to perform this operation from what is currently available in straight WCF async calls.
This article has a short shelf life because after .Net 4 (see What’s Next in C#? Get Ready for Async!) one will use the built in Asynchrony methodology developed. Until that time if one is using any version of Silverlight and WCF then this article describes how to handle those multiple async calls and join the data in a final method call.
Final Result Example
Before delving into the solution, here is how the consumer will use the methodology. Below a user is getting account information of user requests, departments and accounts to join all the data on the view model in the final method for display on a Silverlight page. Thesee operations as shown are setup when the view model class (MyViewModel) is created and no blocking occurs keeping UI thread clear.
public MyViewModel()
{
DataContext = new MyServiceClient();
FinalAsync(CombineDataAndDisplay); // When all the data is retrieved, do this method to combine the data From the 3 async callls below
// Provide the operation as a lambda (could be a method call) to assign data to our target backing store property
// and if all has gone well (no errors in other async calls) and it is the final completing operation. Do the final
// Processing call automatically.
DataContext.GetUserRequestsCompleted += (s, e) => { AssignResultCheckforAllAsyncsDone(e, e.Result, ref _UserRequests, "Acquisition failure for User Requests");};
DataContext.GetAccountsCompleted += (s, e) => { AssignResultCheckforAllAsyncsDone(e, e.Result, ref _Accounts, "Acquisition Failure for Accounts"); };
DataContext.GetDepartments += (s, e) => { AssignResultCheckforAllAsyncsDone(e, e.Result, ref _Departments, "Failed to get Department Info."); };
// Start the Async processes
MultipleAsyncRun(DataContext.GetUserRequestsAsync);
MultipleAsyncRun(DataContext.GetAccountsAsync);
MultipleAsyncRun(DataContext.GetDepartmentsAsync);
// Exit out and return the UI thread to the user operations.
}
// Once all the data is done, combine and assign into our
// PagedCollectionView property for display on the screen.
public void CombineDataAndDisplay()
{
// Combine missing data on the calls
_UserRequests.ToList()
.ForEach(ur =>
{
ur.BillingName = _Accounts.First(ac => ur.AccountID == ac.AccountID).Name;
ur.DepartmentName = _Departments.First(dp => dp.DepartmentID == ur.DepartmentID).Name;
});
UserRequests = new PagedCollectionView( _UserRequests);
UserRequests.GroupDescriptions.Add(new PropertyGroupDescription("DepartmentName"));
}
Microsoft has magic iOS to WP7 conversion tool?
Posted by
jasper22
at
10:22
|
Microsoft has launched a free-to-download interoperability pack to help developers convert existing iOS applications to Windows Phone. But don't get too excited - the result is not as impressive as you might imagine.
If you think about it for even a few moments then it is obvious that one way that Microsoft can pick up some easy apps for its Windows Phone (WP) is to create a converter that reads in an iOS app and spits out a WP Silverlight/XNA app and this is exactly what they haven't done.
What they have done amounts more to encouragement than anything really helpful. The have put together a free to download package of things that might make it a bit easier to convert an iOS app to WP.
The items in the download include a 90-page guide to converting your iOS to WP and a series of "developer stories" - videos of developers talking about how they ported their iPhone apps to WP including why they did it.
The biggest and most useful item in the package is the API mapping tool. This simply takes iOS API calls and lists the nearest equivalents under WP - classes, events and methods are covered. This is undeniably useful but of course it doesn't provide a perfect or automatic solution simply because the structure of the frameworks involved is different. However there are plenty of simple, easy-to-devise, one-to-one mappings - and here is the problem. The mapping tool only does the easy bits and leaves the difficult reimplementation to the programmer. It's a welcome help but not a solution to anything and I doubt it is going to get iOS programmers to convert their programs any faster than they might already have done.

Read more: I Programmer
The Basics of Task Parallelism via C#
Posted by
jasper22
at
10:21
|
Preface
The trend towards going parallel means that .NET Framework developers should learn about the Task Parallel Library (TPL). But in general terms, data parallelism uses the input data to some operation as the means to partition into smaller pieces. The data is divvied up among the available hardware processors in order to achieve parallelism. It is then often followed by replicating and executing some independent operation across these partitions. It is also typically the same operation that is applied concurrently to the elements in the dataset.
Task parallelism takes the fact that the program is already decomposed into individual parts – statements, methods, and so on – that can be run in parallel. More to the point, task parallelism views a problem as a stream of instructions that can be broken into sequences called tasks that can execute simultaneously. For the computation to be efficient, the operations that make up the task should be largely independent of the operations taking place inside other tasks. The data-decomposition view focuses on the data required by the tasks and how it can be decomposed into distinct chunks. The computation associated with the data chunks will only be efficient if the data chunks can be operated upon relatively independently. While these two are obviously inter-dependent when deciding to go parallel, they can best be learned if both views are separated. A powerful reference about Tasks re Compute-bound asynchronous operations is Jeffrey Richter’s book, “CLR via C#, 3rd Edition.” It is a good read.
In this brief article we will focus on some of the characteristics of the System.Threading.Tasks Task object. To perform a simple Task, create a new instance of the Task class, passing in a System.Action delegate that represents the workload that you want performed as a constructor argument. You can explicitly create the Action delegate so that it refers to a named method, use an anonymous function, or use a lambda function. Once you have created an instance of Task, call the Start() method, and your Task is then passed to the task scheduler, which is responsible for assigning threads to perform the work. Here is example code:
using System;
using System.Threading.Tasks;
public class Program {
public static void Main() {
// use an Action delegate and named method
Task task1 = new Task(new Action(printMessage));
// use an anonymous delegate
Task task2 = new Task(delegate { printMessage() });
// use a lambda expression and a named method
Task task3 = new Task(() => printMessage());
// use a lambda expression and an anonymous method
Task task4 = new Task(() => { printMessage() });
task1.Start();
task2.Start();
task3.Start();
task4.Start();
Console.WriteLine("Main method complete. Press <enter> to finish.");
Console.ReadLine();
}
private static void printMessage() {
Console.WriteLine("Hello, world!");
}
}
To get the result from a task, create instances of Task, where T is the data type of the result that will be produced and return an instance of that type in your Task body. To read the result, you call the Result property of the Task you have created. For example, let's say that we have a method called Sum. We can construct a Task object, and we pass for the generic TResult argument the operation's return data type:
using System;
using System.Threading.Tasks;
public class Program {
private static Int32 Sum(Int32 n)
{
Int32 sum = 0;
for (; n > 0; n--)
checked { sum += n; }
return sum;
}
public static void Main() {
Task<int32> t = new Task<int32>(n => Sum((Int32)n), 1000);
t.Start();
t.Wait();
// Get the result (the Result property internally calls Wait)
Console.WriteLine("The sum is: " + t.Result); // An Int32 value
}
}
Produces:
The sum is: 500500
If the compute-bound operation throws an unhandled exception, the exception will be swallowed, stored in a collection, and the thread pool is allowed to return to the thread pool. When the Wait method or the Result property is invoked, these members will throw a System.AggregateException object. You can use CancellationTokenSource to cancel a Task. we must rewrite our Sum method so that it accepts a CancellationToken, after which we can write the code, creating a CancellationTokenSource object.
Read more: Codeproject
Widget Library for Windows Phone 7
Posted by
jasper22
at
10:19
|
Project Description
Create Windows Phone 7 apps using HTML, CSS and Javascript over the WebBroweser control inside the phone.
Widget Library for Windows Phone 7 allows you to build new applications for Windows Phone 7 in a easy way. You can migrate your widgets from iPhone or Android to Windows Phone 7 with this library. You have access to:
Play music on background
Show notifications
Navigate between pages
Play video
Download files
Save and load files from the IsolatedStorage
The communication between the WebBrowser Control and the Windows Phone 7 Apps is implemented using the script capabilities on the control.
Read more: Codeplex
The Factory Design Pattern in C#
Posted by
jasper22
at
10:18
|
I have recently started to create video clips that explain the classic design patterns (GOF) and their implementation in C#. You can find the video clips and the source code they use available for free at www.CSharpBook.co.il. The video clips were prepared in Hebrew. The following video clip explains the factory design pattern and its implementation in C#.
Read more: Life Michael
Private PGP keys
Posted by
jasper22
at
09:18
|
Just simple search in Google reveal some private PGP keys (it just simple search)
Rea more: Google
DataPager Using MVVM in Silverlight 4
In this short post I will show you how to use the DataPager control using MVVM pattern in silverlight. I have develop navigation application for this example which you can see as shown in the Image 1. Here you can see that I have two control in the home screen one is the DataGrid and the second one is the DataPager control. 

In ViewModel I have only property with the name CustomerList of type PagedCollectionView. I have data store in the xml file with the name of customer which is store in the DataBase folder. I have read the xml file in the constructor of the ViewModel and then populate each record in the List.
public HomeViewModel()
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = new XmlXapResolver();
XmlReader reader = XmlReader.Create("DataBase/Customers.xml");
reader.MoveToContent();
string strXMLString = reader.ReadOuterXml();
XElement element = XElement.Parse(strXMLString);
IEnumerable<xelement> elements = element.Descendants("customer");
Collection<customer> customerList = new Collection<customer>();
foreach (XElement ele in elements)
{
customerList.Add(new Customer
{
CustomerID = ele.Attribute("CustomerID").Value,
City = ele.Attribute("City").Value,
CompanyName = ele.Attribute("CompanyName").Value,
ContactName = ele.Attribute("ContactName").Value,
ContactTitle = ele.Attribute("ContactTitle").Value,
Country = ele.Attribute("Country").Value,
Phone = ele.Attribute("Phone") != null ? ele.Attribute("Phone").Value : "Unkown",
Fax = ele.Attribute("Fax") != null ? ele.Attribute("Fax").Value : "Unkown"
});
}
CustomersList = new PagedCollectionView(customerList);
}
Read more: Asim Sajjad
Get a visual parent of an element in Silverlight
Posted by
jasper22
at
12:50
|
Remember that you don’t have a parent in your control’s constructor -- it hasn’t been added anywhere yet. Use the Loaded event when you look. From there, you can use the VisualTreeHelper.GetParent() method. Sometimes you are looking for a parent of a given name or type. To help out, here’s a quick method I threw together to help you find a parent of a given type:
T GetParentOfType<T>() where T : DependencyObject
{
DependencyObject p = this;
while( p != null && !(p is T))
{
p = VisualTreeHelper.GetParent(p);
}
Read more: Arian Kulp's Site
Fixing MaxItemsInObjectGraph quota Error in WCF Service
Posted by
jasper22
at
12:47
|
I have a WCF Service that occasionally yields a message like this one:
Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota.
Today isn’t the first time I’ve run into this message – I’ve fixed this issue before – but since this is the 2nd or more time I’ve run into it, I thought I’d post a quick resolution here so I can find it again later myself, and perhaps help some others. There’s a rather long forum thread on this subject that ultimately includes the solution, but digging it out is a bit painful as is the case with so many forum threads, so I’ll sum up here and just give you what you need.
First, you need to realize that to resolve this issue you will need configuration elements to be specified on both the client and the server. In both cases, the configuration you are looking for is going to be in a named <behavior> as part of a <dataContractSerializer> element. Your service’s configuration might look like this:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DefaultBehavior" name="MyService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_MyService" contract="IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
I notice that my <behavior /> specifies a MaxItemsInObjectGraph value but I don’t know that that is necessary. I’ve left it here since it’s what I actually have working in production, but the solution I found online only indicates the need for the dataContractSerializer maxItemsInObjectGraph (note case) value. For the client, the configuration should look like this:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="ClientBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
Read more: Steve Smith
WCF service that will push content into a Silverlight application [Push notification]
Posted by
jasper22
at
12:46
|
Introduction
Push notification is a term that has been around a lot. Almost every SmartPhone manufactured has an option for enabling push notification. The word 'PUSH' is a contrast to 'PULL'. It means rather than pulling the content from the server or requesting from the server, the server pushes the content or sends the response as soon as an update is available. On mobiles, this technology is a great battery saver. In web technologies, it saves a lot of server request traffic. There are tons of articles available on the internet about implementing this technique, but I found MSDN the best. Therefore, I went ahead and made the MSDN tutorial even easier for beginners. Remember, this is beginners article, but the idea of implementing a real life application stays around this. You can recode it as best as you can.
Over here, we are going to see a Silverlight application requesting for stock prices of Yahoo! The server will start pushing the latest stock prices. The stock prices are random numbers. The application is based on some assumptions.
Background
As a newbie, you must be aware of WCF, basic Silverlight, and terms like Push notification. Please refer to Wikipedia for the definitions.
Using the code
I have used .NET Framework 4.0 to develop the example. You might have to change some code if you are using an earlier version.
Go to the new project and create a WCF Service Application. The first thing to add is the reference to the Polling Duplex DLL. You need to browse in your Add References window to %Program Files%\Microsoft SDKs\Silverlight\v3.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll. Please look carefully, we are referencing the polling duplex DLL from the libraries\server folder.
Right click the project and add a new item 'Interface'. You can name it IService1.cs.
You must include these in the header area--> using System.ServiceModel; and using System.ServiceModel.Web;.
Copy-paste the following code. Basically, we have defined two interfaces within this interface. IsOneWay=true is a messaging pattern which means 'call and forget' in contrast to 'request-response'.
Read more: Codeproject
"Group Policy for Beginners" from Microsoft
Posted by
jasper22
at
12:45
|
Introduces Group Policy, provides an overview of what you can do with Group Policy, describes essential concepts that you must know, and provides step-by-step instructions for the most common Group Policy tasks
File Name: GroupPolicyforBeginners.docx
Size: 836KB
Version: April 2011
Date Published: 4/28/2011
Group Policy is the essential way that most organizations enforce settings on their computers. This white paper introduces Group Policy, provides an overview of what you can do with Group Policy, describes essential concepts that you must know, and provides step-by-step instructions for the most common Group Policy tasks.
..."
Group Policy is one of those things that you either know or don't. You're either a victim of it (at the mercy of it being inflicted on you, etc, etc) or in control of it. And there's a good chance that someone in your organization can and will make changes that reach out and impact you. So, even as a developer or power user, the more you know the better off you'll be.
Read more: Greg's Cool [Insert Clever Name] of the Day
How to Add WPF to VSTO
Posted by
jasper22
at
12:01
|
שילוב WPF באפליקציית VSTO מעשיר מאוד את חוויית המשתמש. לדוגמא:

להלן השלבים לשילוב Control של WPF באפליקציית VSTO ב-Visual Studio 2010:
1. יצירת פרוייקט Office Add-in לדוגמא Word Add-in
2. Add Item ובחירה של
Ribbon (Visual Designer)
3. Add Item ובחירה של
Windows Form
4. Add Item ובחירה של
User Control (WPF)
5. הוספת רכיב Button ל-Ribbon
6. הקוד של הכפתור, לדוגמא:
WindowsForm form = new WindowsForm();
form.Show();
7. מה-ToolBox, הוספת Control בשם ElementHost מתוך קבוצה בשם WPF Interoperability לתוך ה-Windows Form
8. נפתח Design לבחירת User Control של ה-WPF בפרוייקט.
Read more: Dudi Nissan's Blog
ASP.NET 4.0 Chart Control
Posted by
jasper22
at
11:59
|
The Visual Studio 2010 provides us with a Chart control we can use for creating more than 30 different types of charts. We can easily add is to our web page. The Chart control is available within the toolbox data category.
The data can be easily added into the *.aspx document. The following video clip shows that possibility.
Read more: Life Michael
ASP.NET Forms Authentication
Posted by
jasper22
at
11:58
|
The Forms Authentication is a token based system that takes care of users authentication through a log-in form. When a user requests an ASP.NET web page that is not available for anonymoujs users the ASP.NET runtime verifies that the form authentication tocken is available.
Read more: Life Michael
Microsoft Expression Blend Preview for Silverlight 5
Posted by
jasper22
at
10:12
|
Overview
Expression Blend Preview for Silverlight 5 provides support for creating Silverlight 5 Beta projects, including Silverlight 5 Beta SketchFlow projects. Expression Blend Preview for Silverlight 5 installs side-by-side with Expression Blend 4.
Expression Blend Preview for Silverlight 5 supports only Silverlight 5 Beta projects. For Silverlight 3 and 4 projects or WPF 3.5 and 4, please use Expression Blend 4.
Help us improve Expression Studio by reporting any technical issues.
For more insight into Expression Studio, please see the Expression team blog.
Read more: MS Download
Microsoft Silverlight 5 Beta Tools for Visual Studio 2010 Service Pack 1
Posted by
jasper22
at
10:11
|
Overview
This package is an add-on for Visual Studio 2010 Service Pack 1 to provide tooling for Microsoft Silverlight 5 Beta and Microsoft WCF RIA Services V1.0 SP2 Preview (April 2011). It can be installed on top of either Visual Studio 2010 Service Pack 1 or Visual Web Developer 2010 Express Service Pack 1. It extends existing Silverlight 4 features and multitargeting capabilities in Visual Studio 2010 Service Pack 1 to also create applications for Silverlight 5 Beta using C# or Visual Basic.
This download will install all components necessary for Silverlight 5 Beta and Microsoft WCF RIA Services V1 SP2 Preview (April 2011) development:
Silverlight 5 Beta Developer Runtime
Silverlight 5 Beta SDK (software development kit)
Update for Visual Studio 2010 Service Pack 1 and Visual Web Developer Express 2010 Service Pack 1 (KB2502836)
Microsoft WCF RIA Services V1.0 SP2 Preview (April 2011)
Read more: MS Download
3 dirty little cloud computing secrets
Posted by
jasper22
at
10:07
|
Every overhyped technology has good and bad aspects. The trouble is that few are willing to fill you in on the bad aspects. Doing so is often met with several dozen rounds of being called a hater. Cloud computing is no exception.
Here are the three major cloud computing secrets:
Some public cloud computing providers are falling and will fail.
Public clouds don't always save you money.
Using clouds can get you fired.
Now to the details.
Dirty cloud secret 1: Some public cloud computing providers are falling and will fail. Many of the smaller cloud computing providers are not getting the traction they anticipated and are closing their doors, including some of the older firms. This is largely due to providing a far too tactical solution in a world where strategic solutions are sought. Moreover, newer providers have learned to use other clouds, such as IaaS and PaaS clouds, as their platform, whereas the older providers built their services from scratch and are paying for their own private data center spaces. The new generation of cloud providers based on cheaper back ends is pushing them out of business.
Dirty cloud secret 2: Public clouds don't always save you money. I've covered this topic before. The fact is public clouds are not cheap. If you've already invested in internal infrastructure, public clouds don't always make financial sense. You need to run the numbers.
Read more: Cloud computing
A Tale of Two Compilers
Posted by
jasper22
at
10:06
|
In previous posts, I have hinted at the fact that there is more than one C# compiler on a machine with Visual Studio and .NET Framework installed. Sometimes there are several.
Simply put, when we release Visual Studio we release a compiler referred to as the in-process compiler, or in-proc compiler. We generally also release a new version of the .NET Framework at the same time. In the .NET Framework we also ship a separate compiler: the framework compiler, CSC.EXE. The in-proc compiler is tucked away in a Visual Studio DLL containing a bunch of other code as well. The presence of multiple compilers can result in an awkward servicing story and general confusion.
Why two compilers? Well, that wasn't the original plan, but late in the Visual Studio 2005 cycle, the plan changed. The reason that Visual Studio doesn't just use the framework compiler is for performance. Using the in-proc compiler avoids the cost of spinning up another process, and it also reuses a database of interned strings. These issues may not seem significant today, but at one time they had a real performance impact.
The downside of using the in-proc compiler is that it limits scalability. The Visual Studio address space is pretty crowded, and compiling large projects takes up a lot of address space. This wouldn't be a concern if Visual Studio spawned CSC.EXE for the build. So if you run into build scalability issues with a Visual Studio full build, you can often work around them by invoking MSBUILD.EXE from the command line supplying the .SLN file.
I hear you saying, "But my Visual Studio is spawning CSC.EXE. I see a message saying so in the output window." When the output window of Visual Studio tells you the command-line it is invoking CSC.EXE with, don't believe it. Visual Studio is calling the in-proc compiler with the equivalent switches, not the framework compiler. This may change for future versions of Visual Studio, but in Orcas, you're getting the in-proc compiler.
The presence of two compilers per release can pose a problem for servicing. Visual Studio and .NET Framework generally have two different servicing schedules. This means that sometimes users may see a fix in Visual Studio but not in CSC.EXE or vice versa. For service packs to Visual Studio 2005 and .NET Framework 2.0 this is definitely the case. Several more bugs were fixed in CSC.EXE in .NET Framework 2.0 SP1 (and SP2) than were in Visual Studio 2005 SP1. Thankfully, servicing of .NET Framework 3.5 and Visual Studio 2008 is happening at almost the same time. Right now we're working on .NET Framework 3.5 SP1 and Visual Studio 2008 SP1 and all fixes made so far have been made to both compilers.
Read more: I'm just sayin'
Comparing the MVC and MVVM patterns along with their respective ViewModels
Posted by
jasper22
at
10:05
|
It won't take long in your quest to find more information on ASP.NET MVC through internet searches, with bing.com of course, before you'll stumble across the notion of a ViewModel. Mixed within those search results are links to articles on ViewModels in Silverlight/WPF, or other technologies that also use the MVC or MVVM patterns or ViewModels, which can be quite confusing. Having said that, it's no wonder in every presentation I give concerning MVC or ViewModels, a few folks frequently ask these two, quite reasonable, questions:
"What's the difference between MVC and MVVM ?" (in general)
"What's the difference between ViewModels in MVC and ViewModels in MVVM?"
The elevator pitch: MVC is a web UI pattern, and ASP.NET MVC is Microsoft's implementation of it. MVVM is Microsoft's implementation of a desktop UI pattern in WinForms, SilverLight or WPF.
MVC is an old pattern, in use for decades in non-Microsoft platforms, and MVVM is a pattern similar to Martin Fowler's Presentation Model (PM) pattern, as it has taken many of its concepts from PM.
It's all about the patterns
Both MVC and MVVM are patterns, meaning that they are solutions to recurring design problems in software development. Patterns can show interactions between objects in various ways, as the few listed below will demonstrate:
General interactions
Interaction through inheritance and OOP principles
UI interactions
Interaction between models, views, and controllers or models, views, and ViewModels
Data access patterns
ORM mappings, Active Record pattern, POCOs in DALS
Once you're aware of patterns, you can then apply them in software to make your code more stable, consistent, and maintainable. A variety of tools and frameworks exist that can easily help find the best pattern and/or implementation for your specific business problem/domain. In particular, the MVC and MVVM patterns are both UI interaction patterns with MVC being the web UI pattern and MVVM being a desktop UI pattern. You can implement either pattern in Visual Studio, and the ASP.NET MVC project template in particular guides developers to use the MVC pattern.
In addition to MVC & MVVM there are many patterns that are worth reading up on.
Comparing MVC and MVVM: the patterns.
Since MVC and MVVM are geared towards different application paradigms altogether, i.e., ASP.NET MVC for web and MVVM desktop, they need to behave in distinctly different ways, with the most noticeable distinction being the controller from MVC...
Read more: Rachel Appel
10 Must-Have Android Tools for Developers
Posted by
jasper22
at
10:05
|
The Android SDK comes with a robust set of tools to help developers design, develop, test, and publish quality Android applications. In this article, we discuss 10 of the most common tools you should know about and learn to use.
Android Tool #1: Eclipse w/ADT
Although Eclipse is not the only Java development environment that can be used to develop Android applications, it is by far the most popular. This is partially due to its cost (free!) but mostly due the strong integration of the Android tools with Eclipse. This integration is achieved with the Android Development Tools (ADT) plug-in for Eclipse, which can be downloaded from the Android website.
Android Tool #2: The SDK and AVD Manager
This tool serves a number of important functions. It manages the different versions of the Android SDKs (build targets) that you can develop for, as well as third-party add-ons, tools, devices drivers, and documentation. Its second function is to manage the Android Virtual Device configurations (AVDs) you use to configure emulator instances.
Android Tool #3: Android Debug Bridge
The Android Debug Bridge (adb) connects other tools with the emulator and devices. Besides being critical for the other tools (most especially the Eclipse ADT plug-in) to function, you can use it yourself from the command line to upload and download files, install and uninstall packages, and access many other features via the shell on the device or emulator.
Android Tool #4: Dalvik Debug Monitor Server
The Dalvik Debug Monitor Server (DDMS), whether it's accessed through the standalone application or the Eclipse perspective with the same name, provides handy features for inspecting, debugging, and interacting with emulator and device instances. You can use DDMS to inspect running processes and threads, explore the file system, gather heap and other memory information, attach debuggers, and even take screenshots. For emulators, you can also simulate mock location data, send SMS messages, and initiate incoming phone calls.
Read more: developer.com
Silverlight 5 3D Housebuilder Project Shown at MIX11
Posted by
jasper22
at
09:52
|
I presented this application during the MIX11 Day 2 keynote to demonstrate the new 3D features in Silverlight 5 along with a few other new Silverlight 5 features including RelativeSource Ancestor, Data Binding Debugging, Implicit DataTemplates, and Binding in Style Setters.
Download it now
You can download the source for the 3D Housebuilder on the MSDN Code Sample Gallery
Read more: John Papa
Creating a Single-Instance Application in C#
Posted by
jasper22
at
09:51
|
In Visual Basic, there is a checkbox on the application settings form for “Make single instance application”. If this checkbox is checked, then subsequent attempts to launch your application are ignored.
If you hit the “View Application Events” button, you can add a function StartupNextInstance, which is called when the user attempts to launch a second instance of your application.

Unfortunately, in C#, there is no intrinsic capability for single-instance applications. But you can manually add the VB application framework to your C# application. This framework is contained in Microsoft.VisualBasic.dll, so you will need to add a reference to it to your project.
Next, we need to create a class derived from Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase. This class will replace the “Application” instance normally used by C#.
using Microsoft.VisualBasic.ApplicationServices;
class CSApp : WindowsFormsApplicationBase
{
public CSApp(){
EnableVisualStyles = true;IsSingleInstance = true;
}protected override void OnCreateMainForm(){
MainForm = new Form1();
}protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs){
base.OnStartupNextInstance(eventArgs);
}
Read more: JASE Digital Media blog
NXCOMPAT and the C# compiler
Posted by
jasper22
at
09:48
|
The C# compiler in Visual Studio 2008 and the .NET 3.5 Framework (csc.exe) is now generating PE files with the NXCOMPAT bit set. What is that bit and who cares, you ask? You may very well care if your application interops with native binaries or exposes a plugin model to 3rd parties. First, some background...
DEP is short for Data Execution Prevention. It is a technology that exists in Microsoft operating systems which prevents execution of code from memory pages which are not marked as executable. DEP exists to reduce the attack surface available to malicious software that is trying to hijack a process, and it has been acknowledged to be very helpful in that regard. In Windows Vista, the set of processes and applications to which DEP is applied is configurable by administrators, but there is also a role for application developers.
In the header of a PE file there is a flag called IMAGE_DLLCHARACTERISTICS_NX_COMPAT. This flag affects whether or not the OS enables DEP for a process. Setting this flag tells the OS that the image is compatible with DEP. For executable images, if this flag is set, the process is run with DEP enabled unless the machine is configured with the DEP policy set to AlwaysOff. If the image is a DLL and the flag is set, the OS skips checking the DLL against a compatibility database which results in a small performance improvement. All of this applies to x86, 32-bit processes only. On a 64-bit OS, DEP is always enabled for 64-bit processes, but 32-bit processes are configured by the PE flag and system policy as described above. So how does one control the flag in the PE header?
Since the C# compiler emits PE files which are MSIL only and therefore compatible with DEP, the output binaries from the VS 2008 and .NET 3.5 C# compilers have this flag set. Our expectation is that the vast majority of C# executables produced by these compilers will be part of a DEP-compatible application. For that reason we did not surface a compiler switch to configure the NXCOMPAT setting. Of course you can write a C# application that uses a native or mixed binary which is not compatible with DEP. Some ATL types in 7.1 and earlier used to do simple code generation into data pages which is a DEP no-no. If your application is generating IP_ON_HEAP exceptions, then you may need to clear the IMAGE_DLLCHARACTERISTICS_NX_COMPAT flag for your executable. To do this you can use EDITBIN.EXE from the VC toolset like so:
editbin.exe /NXCOMPAT:NO <your binary>
Read more: I'm just sayin'
Why does this query consumes so much CPU?
Posted by
jasper22
at
09:20
|
Recently I worked with a customer who reported a slow running query. Let me simplify this to illustrate the problem.
There are two tables t1 (pk int identity primary key, c1 int, c2 int, c3 int, c4 varchar(50)) and t2 (pk int identity primary key, c1 int, c2 int, c3 int, c4 varchar(50)). Each table has about 10000 rows.
But the following query is very slow.
select COUNT (*) from t1 inner join t2 on t1.c1=t2.c1 and t1.c2=t2.c2 and t1.c3=t2.c3 and t1.c4<>t2.c4
This query runs over 30 seconds and consumes over 30 seconds of CPU. The query actually returns 0 rows. With two tables of size of 10,000 each, this seems to be unreasonable.
When investigate CPU consumption by a query, we normally look at a few things. First, we look at how many logical reads this query has done. Secondly, we look at the plan to see how many rows are processed by each operator.
But when we track logical reads via profiler trace (reads column), we see very low logical reads (less than 60). When we look at the plan, the number of rows processes are not that many either. The partial execution plan is shown below.
Read more: CSS SQL Server Engineers
Getting Started with Script#
Posted by
jasper22
at
09:18
|
At MIX11, I presented a session on Script# titled "Script#: Compiling C# to JavaScript" ... and I did a follow up blog post highlighting the key points from the presentation.
This blog post covers the Hello World demo, which will show how you can get started with script#, and deploy scripts authored using this approach. It doesn't go into more advanced topics, but hopefully it will also demonstrate a couple of key principles at play:
- Script# doesn't introduce some new and odd abstractions. You're still very much authoring script against the DOM and standard APIs, and existing knowledge of web development carries forward.
- The generated script is similar to script you might have authored directly, and can be distributed or deployed into a web application like any other script library, without a dependency on the compiler at runtime.
Script# enables you to leverage Visual Studio, C# syntax and existing familiar and robust set of .NET tools to scripting. In my MIX talk, I demonstrated some of this. In this post, you'll see some basic benefits such as intellisense and compile errors.
Creating a Script# Project
I am going to start with a solution that contains an ASP.NET Web Application (DemoWeb), which is going to contain my pages and scripts. I can of course deploy script#-generated scripts into any server application.
Next I am going to add a Script Library project, named DemoScript. This is a project template that gets installed into Visual Studio when you install script#. The project template creates a C# project, with a custom msbuild target that invokes the script# compiler msbuild task after the C# compiler is done with its part to produce an assembly.
Read more: nikhilk.net
WCF Architecture
Posted by
jasper22
at
09:17
|

Contracts
Contracts layer are next to that of Application layer. Developers will directly use this contract to develop the service. We are also going to do the same now. Let us see briefly what these contracts will do for us and we will also know that WCF is working on message system.
Service Contracts
Service contracts describe the operation that service can provide. Example, Service provided to know the temperature of the city based on the zip code. We call this service as Service contract. It will be created using Service and Operational Contract attribute.
Data Contract
It describes the custom data type which is exposed to the client. This defines the data types, and is passed to and from service. Data types like int, string are identified by the client because it is already mention in XML schema definition language document, but custom created class or datatype cannot be identified by the client, e.g., Employee data type. By using DataContract, we can make client aware that we are using Employee data type for returning or passing parameter to the method.
Message Contract
Default SOAP message format is provided by the WCF runtime for communication between Client and service. If it is not meeting your requirements, then we can create our own message format. This can be achieved by using Message Contract attribute.
Policies and Binding
Specify conditions required to communicate with a service, e.g., security requirement to communicate with service, protocol and encoding used for binding.
Service Runtime
It contains the behaviors that occur during runtime of service.
- Throttling Behavior- Controls how many messages are processed
- Error Behavior - Specifies what occurs, when internal error occurs on the service
- Metadata Behavior - Tells how and whether metadata is available to outside world
- Instance Behavior - Specifies how many instances of the service have to be created while running
- Transaction Behavior - Enables the rollback of transacted operations if a failure occurs
- Dispatch Behavior - Controls how a message is processed by the WCF Infrastructure
Messaging
Messaging layer is composed of channels. A channel is a component that processes a message in some way, for example, by authenticating a message. A set of channels is also known as a channel stack. Channels are the core abstraction for sending messages to and receiving messages from an Endpoint. Broadly, we can categories channels as:
Transport Channels
Handle sending and receiving messages from network. Protocols like HTTP, TCP, name pipes and MSMQ.
Protocol Channels
Implement SOAP based protocol by processing and possibly modifying message. E.g. WS-Security and WS-Reliability.
Read more: Codeproject
Automatic Decompression in WCF
Posted by
jasper22
at
09:16
|
WCF services that are hosted in IIS can take advantage of compression without making any special encoder changes. In Windows Server 2008 R2, IIS compression is actually turned on by default and WCF as of .Net 4.0 supports decompression by default. So if you've got a WCF web-hosted service on a W2K8R2 server using an HTTP transport, then you don't have to do anything to take advantage of compression. If your goal is to have compression on your services and you meet those criteria, then you can kick back now and don't even have to read the rest of this post.
For the rest of us though, there are many interesting details to consider. I figured a question and answer format would work best to explain the nuances.
Q: I'm using Silverlight. How can I take advantage of compression?
A: The good news is that you don't have to do much. Silverlight itself is not responsible for decompressing the messages from a service. The browser will do that for you. Since all requests are essentially going through the browser, the browser can stick in the Accept-Encoding header in the HTTP message. That signals the web server that the client can handle compressed messages and the web server can then decide to turn compression on or off.
Q: If compression is on by default in W2K8R2, how does that affect performance?
A: With IIS, compression is not just always on or off. IIS can choose to use compression based on a number of parameters. For instance, if the CPU usage on the web server is below a minimum threshold or above a maximum threshold, then compression will be turned off. To keep the response times from being too erratic, IIS only checks every 15 seconds or so (not sure on the exact number). So if you're running a performance test you might get some weird results. For instance, this is a 20 second test where the compression was on at first and the bottleneck was the CPU, so the network usage was low. Then IIS decided to turn off compression because the CPU usage was above the threshold and that sent the network usage to 100%.
Read more: Dustin Metzgar's blog
QuickCode .NET 2010
Posted by
jasper22
at
09:12
|
Project Description
The premier productivity boosting add-in for Visual Studio 2005, 2008, and 2010. A complete rewrite of QuickCode.NET 2005, QuickCode.NET 2010 is now freeware. It features an all-new user interface and much-improved ease of use.
For more information please visit QuickCode.NET 2010 on MOBZystems, Home of Tools.
Read more: Codeplex
How to sign a binary that you don't have the sources for?
Posted by
jasper22
at
09:11
|
Hi, it has been a long time since my last post here and that's not because I didn't bump into difficult problems that I wasn't able to solve, but rather due to me being too lazy to write.
So I decided to fix this. Also, the issue that I've found took me a long time to solve and it's a bit obscure so I think it's worth the trouble of a post.
Here's the problem: you are creating a dll that you share with other teams and they expect it to be signed (have a strong name). That's easy enough if you have control over all the dependencies... But what if you are using some dependencies that are not signed?
Here are the steps to sign the dependencies:
1. Get a cert. Here's a simple way generate a random key:
sn -k myKey.snk
2. Install this tool (ilmerge): http://www.microsoft.com/downloads/en/details.aspx?FamilyID=22914587-b4ad-4eae-87cf-b14ae6a939b0&displayLang=en
3. Run ilmerge like this:
ilmerge oldDll.dll /keyfile:mykey.snk /out:newDll.dll
4. Verify if this operation worked:
sn -T newDll.dll
......
Public key token is ea744189c88093ee
Read more: Ionutz's tech blog
Memory Leak Detector including CallStack Info for x86/x64 c++
Posted by
jasper22
at
09:11
|
Project Description
i have rewrited this sources which were by David A. Jones to run in x64 and x86 mode.
Read more: Codeplex
Ubuntu Linux 11.04, "Natty Narwhal," Now Available
Ubuntu Linux, easily one of the most popular Linux distributions available today, is out with what may be its most significant set of changes to date. 11.04 "Natty Narwhal" has brought with it not just major version jumps for nearly every core app and service, but also a completely revamped Unity interface.
Earlier this month, we took an extensive tour through the beta release of Ubuntu's latest, and things have mostly improved since then. The beta's may have been rough around the edges, but 11.04 is now stable and it feels the part.
Love it or hate it, Unity is clearly here to stay. It's been through a major update since 10.10. The interface still does sit atop the GNOME Desktop Environment, though—so things aren't so different once you get past the layout and some basic control maneuvers. It's worth noting, though, that users can select "Ubuntu Classic" from the login screen to switch to a possibly more familiar, more GNOME-like desktop.
Read more: Lifehacker
Subscribe to:
Posts (Atom)