Thursday, June 30, 2011

Funny Japan Commercial


-------
This email message and any attachments thereto are intended only for use by the addressee(s) named above, and may contain legally privileged and/or confidential information. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the jjasper22@gmail.com and destroy the original message.

Posted via email from Jasper-Net

Debugging managed code memory leak with memory dump using windbg

Debugging memory leak is a must-have skill for most server side app developers especially when you move to cloud.  Usually you don't have luxury to attach debugger to the running process on the server. Even if you have the luxury, it might not be as easy as you think. A good solution to this problem which many developers are using is getting memory dump for the process in which you suspect there is memory leak and then debugging it with windbg.

In summary, the below are reasons for using windbg to debug managed code memory leak with memory dump.
 1. It is needed for server side applications and especially cloud applications
 2. Creating memory dump is easy and you can analyze it offline as long as you want
 3. Windbg is powerful, relatively lightweight and free!
 
This task is not as hard as it sounds like. I just simply used the below 9 steps to debug one possible memory leak at work a while back.

 1. .symfix  and .reload -f
 2. .loadby sos mscorwks!
 3. !VerifyHeap
 4. !EEHeap
 5. !dumpheap -stat
 6. !dumpheap -type
 7. !do
 8. !threads
 9. kb
 
Let's see how I debug the memory leak easily one step by one step.  I will give brief description for each step.

 1. .symfix  and .reload -f
 The idea here is finding correct symbols. If .symfix doesn't work, you will need to set the symbol path manually from the menu or use .sympath. This is important and make sure to do it right. Debugging  without symbols is harder and very inconvenient.
 
 2. .loadby sos mscorwks
 sos is the debugger extension for managed coding debugging. Type !help to see what command are available and how to use them. The help is really useful and do read it.  The commands are case insensitive and there are also shortcuts for some commands.

Read more: Paul Lou's blog
QR: debugging-managed-code-memory-leak-with-memory-dump-using-windbg.aspx

Posted via email from Jasper-Net

Creating Wildcard Certificates with makecert.exe

Be nice to be able to make wildcard certificates for use in development with makecert – turns out, it’s real easy.  Just ensure that your CN=  is the wildcard string to use.

The following sequence generates a CA cert, then the public/private key pair for a wildcard certificate

REM make the CA
rem CA Certificate:
makecert -r -pe -n "CN=AA Contoso Test Root Authority" -ss CA -sr CurrentUser -a sha1 -sky signature -cy authority -sv CA.pvk CA.cer -len 2048


REM now make the server wildcard cert
makecert -pe -n "CN=*.contosotest.com" -a sha1 -len 2048 -sky exchange -eku 1.3.6.1.5.5.7.3.1 -ic CA.cer -iv CA.pvk -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sv wildcard.pvk wildcard.cer

pvk2pfx -pvk wildcard.pvk -spc wildcard.cer -pfx wildcard.pfx

Read more: Shawn Cicoria
QR: creating-wildcard-certificates-with-makecert-exe.aspx

Posted via email from Jasper-Net

What happens to WPARAM, LPARAM, and LRESULT when they travel between 32-bit and 64-bit windows?

The integral types WPARAM, LPARAM, and LRESULT are 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems. What happens when a 32-bit process sends a message to a 64-bit window or vice versa?

There's really only one choice when converting a 64-bit value to a 32-bit value: Truncation. When a 64-bit process sends a message to a 32-bit window, the 64-bit WPARAM and LPARAM values are truncated to 32 bits. Similarly, when a 64-bit window returns an LRESULT back to a 32-bit sender, the value is truncated.

But converting a 32-bit value to a 64-bit value introduces a choice: Do you zero-extend or sign-extend?

The answer is obvious if you remember the history of WPARAM, LPARAM, and LRESULT, or if you just look at the header file.

The WPARAM is zero-extended, while LPARAM and LRESULT are sign-extended.

If you remember that WPARAM used to be a WORD and LPARAM and LRESULT used to be LONG, then this follows from the fact that WORD is an unsigned type (therefore zero-extended) and LONG is a signed type (therefore sign-extended).

Read more: The old new thing
QR: 10181137.aspx

Posted via email from Jasper-Net

Writing a C library, part 1

This is part one in a series of blog-posts about best practices for writing C libraries.


Base libraries
Since libc is a fairly low-level set of libraries, there exists higher-level libraries to make C programming a more pleasant experience including libraries in the GLib and and GTK+ stack. Even while the following is going to be somewhat GLib- and GTK+-centric, these notes are written to be useful for any C code whether it's based on libc, GLib or other libraries such as NSPR, APR or some of the Samba libraries.

Most programmers would agree that it's usually a bad idea to implement basic data-types such as string handling, memory allocation, lists, arrays, hash-tables or queues yourself just because you can - it only makes code harder to read and harder to maintain by others. This is where C libraries such as GLib and GTK+ come into play - these libraries provides much of this out of the box. Plus, when you end up needing non-trivial utility functions (and chances are you will) for, say, Unicode manipulation, rendering complex scripts, D-Bus support or calculating checksums, ask yourself (or worse: wait until your manager or peers ask you) if the decision to avoid a well-tested and well-maintained library was a good decision.

In particular, for things like cryptography, it is usually a bad idea to implement it yourself (however inventing your own algorithm is worse); instead, it is better to use an existing well-tested library such as NSS (and even if you do, be careful of using the library correctly). Specifically, said library may even be FIPS-140 certified which is a requirement if you want to do business with the US government.

Read more: inactivity log for davidz
QR: writing-c-library-part-1.html

Posted via email from Jasper-Net

Use it or lose it! [New Delay.FxCop code analysis rule helps identify unused resources in a .NET assembly]

My previous post outlined the benefits of automated code analysis and introduced the Delay.FxCop custom code analysis assembly. The initial release of Delay.FxCop included only one rule, DF1000: Check spelling of all string literals, which didn't seem like enough to me, so today's update doubles the number of rules! :) The new rule is DF1001: Resources should be referenced - but before getting into that I'm going to spend a moment more on spell-checking...

 

What I planned to write for the second code analysis rule was something to check the spelling of .NET string resources (i.e., strings from a RESX file). This seemed like another place misspellings might occur and I'd heard of other custom rules that performed this same task (for example, here's a sample by Jason Kresowaty). However, in the process of doing research, I discovered rule CA1703: Resource strings should be spelled correctly which is part of the default set of rules!

To make sure it did what I expected, I started a new application, added a misspelled string resource, and ran code analysis. To my surprise, the misspelling was not detected... However, I noticed a different warning that seemed related: CA1824: Mark assemblies with NeutralResourcesLanguageAttribute "Because assembly 'Application.exe' contains a ResX-based resource file, mark it with the NeutralResourcesLanguage attribute, specifying the language of the resources within the assembly." Sure enough, when I un-commented the (project template-provided) NeutralResourcesLanguage line in AssemblyInfo.cs, the desired warning showed up:

CA1703 : Microsoft.Naming : In resource 'WpfApplication.Properties.Resources.resx', referenced by name
'SampleResource', correct the spelling of 'mispelling' in string value 'This string has a mispelling.'.

In my experience, a some people suppress CA1824 instead of addressing it. But as we've just discovered, they're also giving up on free spell checking for their assembly's string resources. That seems silly, so I recommend setting NeutralResourcesLanguageAttribute for its helpful side-effects!

    Note: For expository purposes, I've included an example in the download: CA1703 : Microsoft.Naming : In resource 'WpfApplication.Properties.Resources.resx', referenced by name 'IncorrectSpelling', correct the spelling of 'mispelling' in string value 'This string has a single mispelling.'.

Read more: Delay's Blog
QR: use-it-or-lose-it-new-delay-fxcop-code-analysis-rule-helps-identify-unused-resources-in-a-net-assembly.aspx

Posted via email from Jasper-Net

Python and vim: Make your own IDE

I prefer to use vim for most of my systems administration and programming related editing tasks. Aside from the usual argument that it will be present on any *nix system worth its silicon that you log in to, I choose it because of the succinct and expressive power of its syntax. While I am still learning new commands and techniques all the time, and while it is true that the learning curve to be anything resembling proficient is rather steep, few editors can boast such a wide range of actions in so few commands.

Right of out the box, however, vim isn’t as suited to editing Python code as it could be. In fact, it’s rather annoying to write Python code with an uncustomized instance of vim. What follows is a description of how to put into place what I see as the most essential features of the editor one chooses to write code, especially Python code, in as manifested with vim. With the following changes, you can create a highly customized and powerful IDE, allowing you to increase your productivity without purchasing a commercial offering.

Before the good stuff, a few requirements. You need to make sure you have vim-full and vim-python installed. Some systems come with vim-minimal, which is lacking in many advanced features. These packages should be in most repositories.

Aside from these package installs, configuration changes described are made in ~/.vimrc. A quick word on the syntax of this file. Double quotation marks denote a line as a comment. I make it a rule to place a comment line before every configuration line or block thereof, so I have some sense later of what the change was for (it’s amazing how fast syntax leaks out of my head when I don’t use it regularly). Regarding Python files, I eventually also began to collect the related customizations into a file “~/.vim/ftplugin/python.vim”. This is loaded whenever Python type files are opened, and allows me to isolate related configurations.
Syntax highlighting

Having code displayed with proper highlighting of the logical components makes reading that code easier to read and understand. Any decent code editor allows for coloring particular to a number of languages, and vim is no exception. To get this working, simply add:

syntax on


Read more: tail -f findings.out
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/

Posted via email from Jasper-Net

Tutorial – Awesome 3D Parallax Background Effect with jQuery

parallax_tutorial_featured1-610x250.jpg

The HTML

Our page will consist of 6 sections: header, footer and 4 articles. On the right, we’ll place an unordered list that links between the articles and remains fixed on the page so it doesn’t move.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" ></script>
<script type="text/javascript" src="scripts/nbw-parallax.js"></script>
<script type="text/javascript" src="scripts/jquery.inview.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#nav').localScroll();
})
</script>

To start, at the top of the page, we’ll reference all of the JavaScript files we’ll use to make the effect work. The scripts we’re using are:

jQuery 1.4.4
The script written by Ian Lunn (which we’ll cover shortly)
jQuery Inview (determines whether a particular article is in view)

Inside of our body tag, we have the containers that will make up each article.

<div id="intro">
    <div class="story">
        Article content here
    </div> <!--.story-->
</div> <!--#intro-->


Read more: Despiration
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://despiration.com/2011/06/tutorial-awesome-3d-parallax-background-effect-with-jquery/

Posted via email from Jasper-Net

Manual Validation with Data Annotations

Several people have asked me about using data annotations for validation outside of a UI framework, like ASP.NET MVC or Silverlight. The System.ComponentModel.DataAnnotations assembly contains everything you need to execute validation logic in the annotations. Specifically, there is a static Validator class to execute the validation rules. For example, let's say you have the following class in a console mode application:

public class Recipe
{
    [Required]
    public string Name { get; set; }
}

You could validate the recipe with the following code:

var recipe = new Recipe();
var context = new ValidationContext(recipe, serviceProvider: null, items: null);
var results = new List<ValidationResult>();

var isValid = Validator.TryValidateObject(recipe, context, results);

if (!isValid)
{
    foreach (var validationResult in results)
    {
        Console.WriteLine(validationResult.ErrorMessage);
    }
}

Result: "The Name field is required".

You can construct the ValidationContext class without a service provider or items collection, as shown in the above code, as they are optional for the built-in validation attributes. The Validator also executes any custom attributes you have defined, and for custom attributes you might find the serviceProvider useful as a service locator, while the items parameter is a dictionary of extra data to pass along. The Validator also works with self validating objects that implement IValidatableObject.

public class Recipe : IValidatableObject
{
    [Required]
    public string Name { get; set; }

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        // ...
    }
}


Read more: Ode to code
QR: manual-validation-with-data-annotations.aspx

Posted via email from Jasper-Net

Eyesight to the Blind – SSL Decryption for Network Monitoring

SSL and network monitoring aren’t the most compatible of partners – even with the most sophisticated detection infrastructure in the world, you’ll not derive many useful indicators from the barren randomness of encrypted traffic. Consider the plight of the Sguil sensor shown below:

062111_1907_Eyesighttot1.png

The webserver’s use of SSL means that network-based incident detection is problematic. No amount of tuning of the sensor’s Snort instance will help it detect intrusion attempts – the only traffic it will see is HTTPS. Also, if an incident is detected by other means (e.g., customer notification, web server log file monitoring, etc.) the investigative value of Sguil’s full packet capture is greatly diluted.

There are a number of ways to get back the visibility stolen by SSL, including the following. You could:

    Terminate the SSL “in front of” the webserver, perhaps on a reverse-proxying loadbalancer or web application firewall. You can then monitor the decrypted traffic between the loadbalancer and the webserver.
    Perform monitoring tasks on the webserver itself, perhaps by increasing the level of web and application logging.
    Give your existing sensor platforms the means to decrypt the SSL sessions.

Each approach has its pros and cons; this article will show you how to leverage the latter technique to restore the eyesight of your blind Sguil sensors.
SSL Decryption

We first need to understand a little about the mechanics of SSL decryption; you can read about it in depth here. In a nutshell there are two conditions that must be met before we can proceed:

    The server must be using the RSA key exchange mechanism (see here, bottom of page, and here, section F.1.1.2). Fortunately, this is the most common form of key exchange for SSL based servers; if you’re using DSA keypairs or the Diffie-Hellman key exchange mechanism you’re probably out of luck.
    You must have access to the server’s private RSA key, and be able to copy it onto your Sguil sensor.

The latter point means that the only SSL decryption we’re going to be able to pull off is decryption of traffic to and from servers that we own – we’re not going to be able to magically decrypt arbitrary SSL traffic (darn!) However, this is quite adequate from the viewpoint of intrusion detection and network forensics.

Read more: InfoSec
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://resources.infosecinstitute.com/ssl-decryption/

Posted via email from Jasper-Net

Tuesday, June 28, 2011

XML Pipelines: the Process Description

The world of XML is moving fast, in its twelve year old history has raised many technologies. Many ways to validate, transform or query the data carried by the XML. Actually the validations and the transformations are commonly used together in the processes today so commonly called XML Pipelines.

XML Pipeline
By definition “XML Pipeline is formed when XML processes, especially XML transformations and XML validations, are connected together”, that means if we send the output of the validation as input to the transformation (and that is a common use case), we have just created XML Pipeline, more accurately the linear XML Pipeline. Well non-linear pipeline would be the one, where we decide between two process branches based on a condition, where we are looping, running parallel branches or handling errors on the fly.

XProc, W3C Recommended XML pipeline language
XProc is a XML language describing processes, using XSLT for transformations and the XSD, RelaxNG or the Schematron for validation. The greatest thing about XProc is that you describe processing of the XML document by XML language, using the W3C standards on the way.

There is a catch
Well with the XProc, we describe the process by one language, validate by another language and transform by yet another language. By using the three different languages for describing even the simplest use case of the XML Pipelining, a huge space for flaws opens. If we want to make something as trivial as changing the name of one element, we have to make changes in three different languages.

An alternative exist, it’s called XDefinition
If you remember my previous article called “XML Processing and Validation Merging Together” where I wrote briefly about an interesting XML technology called XDefinitions, you will find one language able to transform and validate XML. And because its ability to validate the multiple inputs, transform them, and validate output again, all written in only one highly readable language, the space for the errors is limited to unavoidable minimum.

xmlpipeline.png

Read more: Javalobby

Posted via email from Jasper-Net

Accessing WCF service without creating Proxy

Each time when we want to consume a WCF service, we need to create proxy at client side. To create proxy, service must expose metadata endpoint.

Normally
We create a WCF service
Expose metadata endpoint
Add service reference at client side to create the proxy.
Using the proxy calls the service operation contracts.

Normally we call the service as
MyServiceContractClient proxy = new MyServiceContractClient();
var res = proxy.GetData(9);

Let us assume we want to call the service using channel without creating proxy or adding the service reference.  We need to follow the below steps

Step 1

Put all the DataContract or ServiceContract in a separate DLL or class library. Add the reference of System.ServiceModel in class library.  And create the service contract as below,

MyServiceContract.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ContractDll
{
 [ServiceContract]
   public  interface MyServiceContract
   {
     [OperationContract]
     string GetData(int value);
   }
}

Assume we have created a service library called ContractDLL.

Step 2

Create a WCF Service application and implement the service contract created in step 1. For that add the reference of project created in step 1 in WCF service application.

Read more: C# Corner

Posted via email from Jasper-Net

CyanogenMod 7.1 RC1 now available for download

cm7-nightlies-1-300x209.jpg

CyanogenMod 7.1 RC1 is now available. This is first official release for the new CM 7.1 and it brings Android up to 2.3.4.

Many of you have been running nightly builds of CM7 so these changes are not new, but for those of you that like stable builds and want some nice improvements, you will want to flash this update.

Full changelog after the break

Changelog:

    Common: Android 2.3.4 (Google)
    Common: Bluetooth mouse support – Scott Brady
    Common: Improve notification swipe-to-clear – Evan Charlton
    Common: Improve album-artist support in media scanner – Paul Crovella
    Common: Profile improvements and bugfixes – Martin Long
    Common: RTL text improvements – Eyad Aboulouz, Eran Mizrahi
    Common: Wake on volume key option – Sven Dawitz
    Common: Support for revoking application permissions – Plamen K. Kosseff
    Common: Latest Superuser app – ChainsDD
    Common: Control brightness by sliding on statusbar – Danesh M
    Common: Add “copy all” to context menu – Danesh M
    Common: Lockscreen haptic and statusbar indicators toggle – Danesh M
    Common: Nicer timepicker/datepicker – Jiri Tyr
    Common: Configuration 0/90/180/270 rotation – Jonas Larsson, Scott Brady
(more...)


Read more: Talk Android
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://www.talkandroid.com/44395-cyanogenmod-7-1-rc1-now-available-for-download/

Posted via email from Jasper-Net

20 WebGL sites that will blow your mind

WebGL, released earlier this year, is the new standard for high-quality 3D graphics in web pages. Giles Thomas of LearningWebGL.com rounds up 20 of the best sites so far

Almost all modern computers and most smartphones have powerful GPUs, graphics processors that often have more number-crunching power than the CPU. But until recently web pages couldn't use them — meaning slow, low-quality graphics, almost always in 2D.

That all changed when WebGL was released in the latest versions of Firefox and Chrome.  WebGL, based on the well-known OpenGL 3D graphics standard, gives JavaScript plugin-free access to the graphics hardware, via the HTML5 canvas element — making realtime 3D graphics in web pages possible.


1. ROME: "3 Dreams of Black"

rome.gif

"3 Dreams of Black" is a semi-interactive film by Chris Milk, using technology developed by Google and others, featuring the song "Black" from the album ROME by Danger Mouse and Daniel Luppi, with Norah Jones and Jack White. It takes you through three separate dreams, mixing 2D and 3D computer graphics with video. It works best on Chrome. Read our report here: www.netmagazine.com/news/rome-project-showcases-webgl.

Read more: .NET beta
QR: 20-webgl-sites-will-blow-your-mind

Posted via email from Jasper-Net

Don’t write it, read it instead!

The bootkit malware Trojan:Win32/Popureb.E has made some changes in its code compared to previous samples (specifically, Trojan:Win32/Popureb.B), and now it introduces a driver component to prevent the malicious MBR and other malicious data stored as disk sectors from being changed. The driver component protects the data in an unusual way – by hooking the DriverStartIo routine in a hard disk port driver (for example, atapi.sys). The following steps describe the trick:

  • It calls IoGetDeviceAttachmentBaseRef( ) to retrieve the bottom device object in the disk device stack, that is, the real physical disk device object.
  • Then it hooks the DriverStartIo routine in the found device's DRIVER_OBJECT structure (see the picture below).
BID563-001.jpg


Read more: Microsoft Malware Protection Center
QR: don-t-write-it-read-it-instead.aspx

Posted via email from Jasper-Net

MarketsPlus Evolve: UX Inspiration from a Great Silverlight Application

Windows-Live-Writer_MarketPlus-Evolve-A-Silverlight-Applicat_EBF7_image_thumb_4.png

At Microsoft we often talk about "consumer" applications and "line of business" applications as separate classes of apps. Sometimes, applications that intersect both worlds come along. A few weeks ago, I was turned on by Scott Hanselman, to a soon-to-be-launched Silverlight application named MarketsPlus Evolve. My immediate impression was that this was an app with an attractive UI with very crisp UX, showing that a lot of thought went into the design.

    Just want to jump into trying it?

use userid of "demo" and password of "demo".

Here are a few screenshots of parts that just jumped out at me.

First, they have a nice pre-loader, without any spinning default blue orbs animation. That is such an easy thing to include in your own applications, but many folks leave them out. It makes an impression, especially when it comes to consumer apps.

Read more: 10Rem.net
QR: marketsplus-evolve-ux-inspiration-from-a-great-silverlight-application

Posted via email from Jasper-Net

Google Quietly Rolls Out WDYL.com: A Range Of Google Product Results On One Page

wdyl.png?w=300&h=144

This morning, we got tipped to check out wdyl.com. The tipster noted that it was apparently a new Google site attempting to “create a unified UI to search in multiple channels”. Sure enough, visiting the URL brought up a Google page — but it was a 404 page. Turns out it needs the “www” in order to work. Yes, wdyl.com is not quite ready for prime-time. But it is out there, live!

The new service, which Google apparently did launch this morning, is called What do you love? (hence, wdyl.com). While it seems to be more of a cute gimmick at this time, the idea is to return users a single page of relevant results across many of Google’s products for whatever query is typed into the wdyl search box. The “search” button is even a heart. Cute.

Read more: TechCrunch
Read more: What do you love ?
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://techcrunch.com/2011/06/27/google-wdyl/

Posted via email from Jasper-Net

Michael’s “Mega Collection of Silverlight 5 Beta” Demos

I’ve decided that today I would release a set of Demos for the Silverlight 5 Beta to help the community get up to speed quickly with the new features. In order to make the Silverlight 5 developer-base grow I will be creating demos of every feature as it is available. Here is my first set of contributions to make this happen.

To download all the demos in one file then click here.

For separate downloads then click below.

Please note: All of these demos were created using the Silverlight 5 Beta and things may change in the final release.

Demo Name Download Location
Ancestor Relative Source MikesAncestorRelativeSource.zip
Click Count MikeClickCount.zip
ComboBox Type Ahead MikesComboBoxTypeAhead.zip
Custom Markup Extensions MikesCustomMarkupExtension.zip
Debugging XAML MikesDebuggingXaml.zip
Debugging XAML (SL 4.0) MikesDebuggingXaml40.zip
Implicit Data Templates MikeImplicitDataTemplateDemo.zip
Linked Text Containers MikesLinkedTextContainers.zip
Multiple Windows MikesMultipleWindows.zip
Save File Dialog MikesSaveFileDialog.zip
Style Binding MikesStyleBinding.zip
Trick Play MikesTrickPlayDemo.zip
Unrestricted File Access MikesUnrestrictedFileAccess.zip
XNA Sound Latency MikesXNASoundLatency.zip


Read more: Michael Crump
QR: michaelrsquos-ldquomega-collection-of-silverlight-5-betardquo-demos.aspx

Posted via email from Jasper-Net

Debug Single Thread

FileDownload.aspx?ProjectName=singlethread&DownloadId=252956&Build=17889

Project Description
This Visual Studio 2010 extension adds two shortcuts and toolbar buttons to allow developers to easily focus on single threads while debugging multi-threaded applications.
It dramatically reduces the need to manually go into the Threads window to freeze/thaw all threads but the one that needs to be followed, and therefore helps improve productivity.

Features:
- Restrict further execution to the current thread only. Will freeze all other threads. Shortcut: CTRL+T+T or snowflake button.
- Switch to the next single thread (based on ID). Will change current thread and freeze all other threads. Shortcut: CTRL+T+J or Next button.

Read more: Codeplex
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://singlethread.codeplex.com/

Posted via email from Jasper-Net

Using Code Signing Certificates to sign downloaded MSIs and build reputation with IE9 SmartScreen

First, let me start that if you want a lot of people to download something, make sure that the words "HTML5," "Support" and "Update" appear in the title. I'm sure if the folks that are making Diablo 3 called it "Diablo 3 HTML5 Support Update" that a metric buttload more people would download it.

That said, a bunch of folks in the Web Platform and Tools team created the Web Standards Update package with HTML5 Support for the Visual Studio 2010 Editor.

This Web Standards Update is something that anyone in the community could have released, just extending Visual Studio in a standard way. Like many other (most) extensions in Visual Studio Extension Gallery, it was not "signed." It was not a formal project done by Microsoft. Ratherthis was something that a bunch of us did for the community in our after work hours.  The only reason why this got in spotlight was because press caught the wind of it having HTML5 and CSS3 support.

Certainly a lot of people wanted it because in 4 days it's now the #1 most popular thing in the Visual Studio Gallery. Take that NuGet! ;)

Here's where the trouble starts. Then, it was written about in the press as if it were a "gaffe." I admit that we (mostly I) did a lousy mediocre job of making it clear that this update was a "community update from the inside," as it were. It's not official, but we're hoping support like this will make its way into the next version of Visual Studio.

When you downloaded the MSI installer with IE9, as with all MSIs that aren't signed, you get a message like this:

clip_image001_thumb.png

And that's normal and quite lovely. Then we see this scary red bar (this is a shot from another gallery item):

smartscreenbad_thumb.png

This is the IE9 SmartScreen system warning us, rightfully so, that this is not something downloaded all the time. In fact, this is a really useful feature of IE9 and is fairly unique amongst the browsers so far. It's using some special sauce (some hash, some math, some metrics) to make a non-biased judgment about this download. Even though it's coming from a Microsoft.com website it doesn't matter. SmartScreen is unbiased. It's never seen this before, and it's not trusted.

UPDATE: Looks like as of my test just now that SmartScreen now recognizes our download as safe!


Read more: Scott Hanselman Computer Zen
QR: UsingCodeSigningCertificatesToSignDownloadedMSIsAndBuildReputationWithIE9SmartScreen.aspx

Posted via email from Jasper-Net

XNA for Silverlight Developers series now available as a fully offline resource


xna_ebook_cover_150.png
SilverlightShow starts launching its most successful article series as fully offline resources! Check out SilverlightShow Ebook area for all available ebook listings!
The first two ebooks released are:

    XNA for Silverlight developers - a 14-part article series by Peter Kuhn
    Working with Collections in WCF RIA Services - a 2-part series by Kevin Dockx
Each ebook package contains a PDF and Word version of the series, packed with all source code. You may instantly download the ebooks right after payment.
We'll be giving some ebooks for free in our webinars and upcoming trainings, so stay tuned for our news and announcements on Twitter, Facebook and LinkedIn!



Read more: SilverlightShow
QR: Get-in-the-game-with-more-that-130-pages-of-XNA-goodness.aspx

יצא Patch חדש ל–Visual Studio 2010 SP1 עבור כלי הבדיקות

לפני מספר ימים הוכרז על Patch חדש ל – Visual Studio 2010 SP1.
ה – Patch מכיל תיקוני באגים בעיקר עבור כלי הבדיקות, רשימה מלאה של התיקונים נמצאת בסוף הפוסט.
ניתן להוריד את ה – Patch מהלינק:
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=36847
יש להתקין Visual Studio 2010 SP1 לפני התקנת ה – Patch.
צירפתי את תיאור הבעיות אותן פותר ה – Patch מאתר ההורדה:
An update rollup is available that resolves the following issues for the testing tools in Microsoft Visual Studio 2010 Service Pack 1 (SP1).
Issue 1
When you run tests on the test agent that is installed on a computer that has Visual Studio 2010 SP1 installed, the tests may not run, and the following error message is logged:
Attempted to access an unloaded AppDomain. (Exception from HRESULT: 0x80131014)
Issue 2
When you run a playback of a Coded UI Test on certain Windows Presentation Foundation (WPF) controls, a Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException exception occurs, and then you receive the following error message:
"Search may have failed at '<name>' <control type> as it may have virtualized children. If the control being searched is descendant of '<name>' <control type> then including it as the parent container may solve the problem."
Notes
    One of the causes of this error message is that the WPF controls are deep in the UI control hierarchy. Therefore, the control cannot be addressed in the recorded QuerID UI control hierarchy in the UI map. After you install this update, the control can be addressed.





Read more: Eran Ruso
QR: New-Patch-For-Visual-Studio-2010-SP1-Testing-Tools.aspx

Silverlight 4.0: Duplex Communication over Http using PollingDuplexHttpBinding

In a real world application, many-a-times it is required that the application performs a two-way communication i.e. the client application sends request to the service and then service should have capability to initiate action itself and send the data back to the client.

In Silverlight, we can perform this kind of operation using Socket programming as well as using Duplex bindings. In Silverlight 4.0, we can do this using net.tcp binding. In this small article, I have used Polling Duplex communication. In WCF service, duplex communication is implemented using PollingDuplexBinding. When you install Silverlight, you get the following path where the polling duplex assembly is stored:

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll

The above assembly reference is used by the WCF Service for the Duplex communication mechanism and the assembly used by the Silverlight client application is available at:

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.ServiceModel.PollingDuplex.dll

Since the communication between Silverlight 4 and WCF is performed using Http, the Silverlight client has to send the request to the service to initiate the communication. Once this connection is established, the PollingDuplexBinding allows the established channel to keep alive, until the timeout occurs.

Let’s see a practical implementation in this article

Step 1: Open VS2010 and create a new Silverlight application, name it as ‘SL4_Duplex_Service’. You will now see the ‘SL4_Duplex_Service.Web’ host project.


Step 2: In the Web host project, add a reference to the ‘System.ServiceModel.PollingDuplex.dll’ from the following path:
C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll


Step 3: In the Web host project, add a new Silverlight enabled WCF service and call it ‘MyService.svc’. Also in the project, add a new Interface file and name it as ‘IService.cs’, the same file will define the ServiceContract and OperationContract as shown below:



silverlight-duplex-service.png




Read more: net curry com
QR: ShowArticle.aspx?ID=726

Discover Amazing Open Source Code With the Freshmeat API

If you’re reading this, I probably don’t have to tell you about Freshmeat. This repository of open source code and projects has been around quite a while, and is used by a number of prominent projects. What you may not know, however, is that Freshmeat offers a well-designed Freshmeat API to help developers access the data on Freshmeat for any purpose that makes sense.

The API is RESTful, and accepts inputs in either JSON or XML. It requires an authentication token, which every active Freshmeat account already has. If you have an account already, get yours here. If not, make yourself an account, then go there. The API is completely free to use, and the only limitation is a request limit of 600 requests per hour.

For those who want even more simplicity, there’s a pretty good Perl library and a Ruby library for using the API. The documentation has a nice list of what one can access through the API:

    This API deals with data gathering and data entry for the following data types:

    Projects
    Comments
    Dependencies
    Project Filters
    Votings
    Releases
    Screenshots
    Subscriptions
    Tags
    URLs
    Search
Now, the question is, what would you build with it?



Read more: ProgrammableWeb
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://blog.programmableweb.com/2011/06/24/discover-amazing-open-source-code-with-the-freshmeat-api/

Working with SortedSet in .NET 4.0

SortedSet is one class that is been added to the .Net class library 4.0 which actually merges the behaviour of HashSet and SortedList together. It maintains the sorted ordering of the list without affecting performance.

Lets see how it works :

SortedSet sorted = new SortedSet { 1, 43, 65, 23, 44, 56, 43, 1, 56, 66, 24 };
 foreach(int number in sorted)
   {
      Console.WriteLine(number);
 }

Console.Read();






Read more: Daily .Net Tips
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://dailydotnettips.com/2011/06/26/working-with-sortedset-in-net-4-0/

Some facts about Null in .NET

As I am tweeting around the facts on Nulls for last couple of days, I thought of writing a blog on that as many of you have already requested me on this regard. This post is basically dealing with Nulls and will go through only with basic C# stuffs, so for geeks, it is not recommended and you might end up knowing a little or almost nothing. So if you just here for time pass, then I refer to read on.

Considering the fact Nulls appear on any objects, we have mainly two categories of programmable storage in .NET.

    Nullables (generally mutable with exceptions like strings)
    Value Types / struct (generally immutable)
Nullables are types that either user defined or in framework in which one of its value can be null. .NET treats null specially. Say for instance :
class Program
    {
        static void Main(string[] args)
        {
            X xobj = null;
            Y yobj = null;
        }
    }
Here both xobj and yobj holds null, but you cannot equate xobj == yobj. It is illegal.
Another important fact is Unassigned local values are not treated as null. .NET compiler throws exception when an unassigned variable is used. But if you declare the member of a class unassigned, it will automatically be assigned to null. Hence :

static void Main(string[] args)
        {
            X xobj;
            Y yobj = null;
            xobj = xobj ?? new X();
        }






Read more: DOT NET TRICKS
QR: some-facts-about-null-in-net.html

Working with BigInteger in .NET 4.0

One of the interesting feature that is added with .NET 4.0 is the support of BigInteger. Big numbers are needed when a number cannot be held with any of the existing data types available with .NET framework.
Long has the highest value of 9,223,372,036,854,775,807 which is 0x7FFFFFFFFFFFFFFF in hexadecimal. This is the highest value of a variable which you can store in .NET. Or rather you can say UInt64 to store the highest value of 18,446,744,073,709,551,615 if you don’t need negatives. But this is not actually sufficient when dealing with certain situations like dealing with yearly analytical reports, statistical data etc.
BigInteger is a new type(struct) introduced in .NET 4.0 which deals with the situation and can store any value. To use it you need to add System.Numarics.dll.

For instance :

BigInteger binteger = new BigInteger(3824783785434543);
Console.WriteLine(binteger);

Here in the constructor I have specified the value with which the binteger is to be initialized. You can also use assignment operator and any operators with this object.

BigInteger binteger = 3824783785434543;
Console.WriteLine(binteger);
Console.WriteLine(binteger > 32948454);
Console.Read();






Read more: Daily .Net Tips
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://dailydotnettips.com/2011/06/27/working-with-biginteger-in-net-4-0/

Using POP3 with C# to download and parse your mail.

Introduction
This article explains a simple way to add mail support in your application. Just use the classes:
POP3class methods:

    string DoConnect(String pop3host,int port, String user, String pwd)
    string GetStat()
    string GetList()
    string GetList(int num)
    string Retr(int num)
    string Dele(int num)
    string Rset()
    string Quit()
    string GetTop(int num)
    string GetTop(int num_mess, int num_lines)
    string GetUidl()
    string GetUidl(int num)
    string GetNoop()
MessageClass methods:
    string GetFrom(string messTop)
    string GetDate(string messTop)
    string GetMessID(string messTop)
    string GetTo(string messTop)
    string GetSubject(string messTop)
    string GetBody(string AllMessage)


Using the code
The following sample illustrates how to use the classes:

POP3class pop3;
pop3 = new POP3class();
pop3.DoConnect("your.mail.server",110,"username","password");
pop3.GetStat();
// and if we have mail:
MessageClass msg;
msg = new MessageClass();
string sMessageTop = msg.GetTop(1);
//OK, message is well, lets download it.







Read more: Codeproject
QR: karavaev_denis.aspx

MMPPF - Getting started guide for the Silverlight Microsoft Media Platform

image%25255B8%25255D.png?imgmax=800

When Silverlight introduced it was considered as a Player Framework because of its capability to handle Rich media. This is one of the first technology to handle true 720p and 1080p HD media. Since its evolution, Silverlight 1 to Silverlight 5 the digital media experience improved a lot. So this post we will take a dig into media concepts and its integration with Silverlight along with various option available.
This post will focus extensively on the Microsoft Media Platform Framework from Microsoft, a open source player framework and its implementation.


Read more: Greg's Cool [Insert Clever Name] of the Day
Read more: Enhancing Media Experience in Silverlight with Microsoft Media Platform (MMPPF)
QR: mmppf-getting-started-guide-for.html

Digital Signing Demo

This post demonstrates the use of a digital signing function to ensure data within a table is unaltered outside a given set of stored procs. To understand how these and other crytographic functions can be employed to improve the security of database applications, please review this post.

The first step in the demonstration is to create an empty database within which sensitive data will be housed:

USE master;
GO

IF EXISTS (SELECT * FROM sys.databases WHERE name = ‘SigningFunctionDemo’)
   DROP DATABASE SigningFunctionDemo;
GO
CREATE DATABASE SigningFunctionDemo;
GO

Next, a table will be created to house some sensitive data.  It’s important to note that for this demonstration, the data is not being encrypted but it could be to make unauthorized access and modifications more challenging:

USE SigningFunctionDemo;
GO

CREATE TABLE dbo.MySensitiveData (
   Id INT NOT NULL IDENTITY(1,1),
   MyData NVARCHAR(25) NOT NULL,
   MySignature VARBINARY(256) NOT NULL
   );
GO

To support signing, an asymmetric key will be created along with two stored procedures making the signing and verification calls on behalf of the application:

CREATE ASYMMETRIC KEY MySigningKey
    WITH ALGORITHM = RSA_2048
    ENCRYPTION BY PASSWORD = N’asd!i36oheQ#wr8iW#%qwei4!orqhq9w7as’;
GO

CREATE PROC dbo.spPutData @MyData NVARCHAR(25)
AS
   INSERT INTO dbo.MySensitiveData (MyData, MySignature)
   SELECT
    @MyData,
    SIGNBYASYMKEY(
         ASYMKEY_ID(‘MySigningKey’),
         @MyData,
         N’asd!i36oheQ#wr8iW#%qwei4!orqhq9w7as’
         );
GO

CREATE PROC dbo.spGetData @Id int
AS
 SELECT
    MyData,
    VERIFYSIGNEDBYASYMKEY(
  ASYMKEY_ID(‘MySigningKey’),
  MyData,
  MySignature
  ) AS IsValid
 FROM dbo.MySensitiveData
 WHERE  Id = @Id;
GO

With this in place, data can now be placed into the database along with a signature:

EXEC dbo.spPutData N’This is my sensitive data’
GO

Accessing the table directly, the data and its signature can be seen:

SELECT * FROM dbo.MySensitiveData
GO

Read more: MSDN Blogs

Daniel Moth: Blazing-fast code using GPUs and more, with C++ AMP

Herb Sutter recently announced C++ AMP at the AMD Fusion Developer Summit as part of his keynote. Here, Daniel Moth, a program manager on Microsoft's Parallel Computing Platform Team, digs deeper into C++ AMP with code samples and more. Please download the slides from the link below as the recording of this session doesn't do them justice.

Big thanks to AMD for providing Channel 9 with this excellent content!

To get full performance out of mainstream hardware, high-performance code needs  to harness, not only multi-core CPUs, but also GPUs (whether discrete cards or integrated in the processor) and other compute accelerators to achieve orders-of-magnitude speed-up for data parallel algorithms. How can you as a C++ developer fully utilize all that heterogeneous hardware from your Visual Studio environment? How can your code benefit from this tremendous performance boost without sacrificing your developer productivity or the portability of your solution? The answers will be presented in this session that introduces a new technology from Microsoft.

Read more: Channel9

How To Remotely Copy Files Over SSH Without Entering Your Password

banner-019.png

SSH is a life-saver when you need to remotely manage a computer, but did you know you can also upload and download files, too? Using SSH keys, you can skip having to enter passwords and use this for scripts!

This process works on Linux and Mac OS, provided that they’re properly configured for SSH access. If you’re using Windows, you can use Cygwin to get Linux-like functionality, and with a little tweaking, SSH will run as well.


Copying Files Over SSH
Secure copy is a really useful command, and it’s really easy to use. The basic format of the command is as follows:

    scp [options] original_file destination_file

The biggest kicker is how to format the remote part. When you address a remote file, you need to do it in the following manner:
    user@server:path/to/file
The server can be a URL or an IP address. This is followed by a colon, then the path to the file or folder in question. Let’s look at an example.

    scp –P 40050 Desktop/url.txt yatri@192.168.1.50:~/Desktop/url.txt

This command features the [-P] flag (note that it’s a capital P). This allows me to specify a port number instead of the default 22. This is necessary for me because of the way I’ve configured my system.



Read more: How-to geek
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://www.howtogeek.com/66776/how-to-remotely-copy-files-over-ssh-without-entering-your-password/

Monday, June 27, 2011

Windows 8 for software developers: the Longhorn dream reborn?

images?q=tbn:ANd9GcQGGVP3wdbIPh2wZ9ZeOxD2-fy9HvDSF_yGtXRKzly8JtTI2r5S&t=1

A brave new world
Windows 8 will ship with a pair of runtimes; a new .NET runtime (currently version stamped 4.5), and a native code C++ runtime (technically, COM, or a derivative thereof), named WinRT. There will be a new native user interface library, DirectUI, that builds on top of the native Direct2D and DirectWrite APIs that were introduced with Windows 7. A new version of Silverlight, apparently codenamed Jupiter, will run on top of DirectUI. WinRT and DirectUI will both be directly accessible from .NET through built-in wrappers.

WinRT provides a clean and modern API for many of the things that Win32 does presently. It will be, in many ways, a new, modern Win32. The API is designed to be easy to use from "modern" C++ (in contrast to the 25 year old, heavily C-biased design of Win32); it will also map cleanly onto .NET concepts. In Windows 8, it's unlikely that WinRT will cover everything Win32 can do—Win32 is just so expansive that modernizing it is an enormous undertaking—but I'm told that this is the ultimate, long-term objective. And WinRT is becoming more and more extensive with each new build that leaks from Redmond.
WinRT isn't just providing a slightly nicer version of the existing Win32 API, either. Microsoft is taking the opportunity to improve the API's functionality, too. The clipboard API, for example, has been made easier to use and more flexible. There will also be pervasive support for asynchronous operations, providing a clean and consistent way to do long-running tasks in the background.

DirectUI is built around a core subset of current WPF/Silverlight technology. It includes support for XAML, the XML language for laying out user interfaces, and offers the rich support for layouts that Win32 has never had. This core will give C++ programs their modern user interface toolkit and, at its heart, it will be the same toolkit that .NET developers use too. (DirectUI is a name Microsoft has used before, internally, for a graphics library used by Windows Live Messenger. The new DirectUI appears to be unrelated.)

Jupiter is essentially Silverlight 6; a fully-featured, flexible toolkit for building applications. The exact relationship between DirectUI and Jupiter isn't entirely clear at the moment. It's possible that they're one and the same—and that DirectUI will grow in functionality until it's able to do everything that Silverlight can do. It's also possible that DirectUI will retain only core functionality, with a more complete framework built on top of its features. Another option is that Jupiter refers specifically to immersive, full-screen, touch-first applications.


Read more: Ars technica
QR: windows-8-for-software-developers-the-longhorn-dream-reborn.ars

Visidon Applock sees your pretty face, grants you Android access (video)

In the event you got lulled into a groovy seat dance by that most excellent muzak above, let us repeat - this app does not protect your lockscreen. That said, Visidon's Applock will prevent the privacy-adverse from messing with your personally curated app collection. Have a nosy significant lover? No sweat -- snap a pick with your front-facing cam, enable the face-lock in your settings, and those sexts are as good as blocked. It's far from foolproof, however, as some comments indicate an extended bit of facial-wriggling tricks the app into unlock mode. Oh well, you're so vain, you'll probably think this Android market link is for you -- don't you?


Read more: Engadget
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://www.engadget.com/2011/06/23/visidon-applock-sees-your-pretty-face-grants-you-android-access/

Providing a great Silverlight deployment experience

If you are doing Silverlight development, you are no doubt slapping in the tag or using the control (if in ASP.NET) to host your Silverlight content/application.  This is all great, but don't forget about deployment!

When I talk about Silverlight I like to relay a story I heard from one of the Silverlight program managers (PM) a while back.  The PM was pretty excited about a feature just completed in Silverlight and one of the samples that had been created.  He went home to show his wife and told her to 'go to 'dub-dub-dub-dot-something-dot-com' (yelling from the other room of course) and to tell him what she thought.  After a long pause of a few minutes he shouted back 'what do you think?'  Her response: 'It's lame.'  He was no doubt offended until he walked up to her machine and on the screen saw this:

?LinkID=92801&clcid=0x409

The Problem

You see, 'Get Silverlight' means nothing to your mother-in-law (or wife in this matter).  Technology means nothing to non-geek users.  Content is king.  And to your non-savvy users (and even your savvy ones), leaving this default experience isn't a wise one.  It doesn't convey that there is anything of value by installing something they might not have.  It doesn't even convey what the action is going to be when they 'Get Microsoft Silverlight.'  Leaving this experience unchecked leaves your users in the dark as well as a reputation rank downward in my opinion.

    NOTE: This site is likely riddled with these badges as seen above.  I'm claiming exempt status because they are samples :-).

While in Silverlight 1.0 creating a great install experience was possible, Silverlight 2 makes that process so much easier.  In Silverlight 1.0, the use of the silverlight.js file could aid in detection and direction to an alternate experience.  This method is still possible in Silverlight 2, and in fact might be a best practice still.  Most interactive developers using Flash use some method of script creation in instantiating the Flash host.  This is mostly due to the IE EOLAS "click to activate" issue that has been resolved and will remedy in an upcoming IE update.

Some Solutions

So that brings a few methods for instantiating the Silverlight control host.  You can still use a script method to do the check for you and provide alternate content or redirect to something.  You can also still simply include the tag itself.  My favorite is using the simple tag and tricking the HTML.  You see an object tag might look like this:


   
   
   
   
Some descriptive information


Read more: Method of ~ failed ~
QR: creating-a-great-silverlight-deployment-experience.aspx

Posted via email from Jasper-Net

Behaviors and Triggers in Silverlight

1. Introduction
With the release of Silverlight 3, a lot of new cool features have been introduced. One of my favorite definitely is the support of behaviors and triggers. In WPF the triggers are extremely powerful. They allow you to declaratively associate an action with an event or property value. In the previous versions of Silverlight one of the things that were really missing were the triggers and the behaviors. It was not possible, for example, to add mouse-overs to objects declaratively (as in WPF). Currently it is still not possible, you have to write procedural code, but at least that code is separated, so the designer doesn’t have to write it or understand it. In that post I will focus exactly on that new feature in Silverlight and will show you how to create your own custom behaviors and triggers.
You can find the demos in the end of each section.

Download Source

2. Prerequisites
In order to write behaviors and triggers you need to have installed the Microsoft Expression Blend SDK on your machine. After that you need to add a reference to the System.Windows.Interactivity.dll assembly which is located in:
{Program Files}\Microsoft SDKs\Expression\Blend 3\Interactivity\Libraries\Silverlight
I don’t know why but this assembly currently is not part of the Silverlight SDK. You can download the Expression Blend product from here.


3. Behavior types
Currently you can use three types of bevahors: Behavour, TriggerAction and TargetedTriggerAction. The class diagram is shown on the next figure:

BehaviorClasses.png


4. Using the Behavior<T> class
For simple scenarios the generic Behavior<T> class is excellent choice. This class has only two overridable methods which notify the current behavior when an object is attached and detached from it. For my post I will create two behaviors: the first one just inverts the color of an image, when the image is clicked, and the second is little more complicated – it adds an animation and creates a magnifier when the mouse is over the image.

The first thing you should do when creating behaviors is to create a new class which inherits from the generic class Behavior<T>, where T is a dependency object. In the most cases you will inherit from the Behavior<FrameworkElement> or Behavior<UIElement>.

public class InverseColorClickBehavior :
    Behavior<FrameworkElement>
{
    public InverseColorClickBehavior() :
        base()
    {
    }
}

For that particular case I am interested in the mouse click event. That’s why in the OnAttached method I will attach to the MouseLeftButtonDown event of the associated with that behavior object. And respectively in the OnDetaching method I will detach from that event.


protected override void OnAttached()
{
    base.OnAttached();
    this.AssociatedObject.MouseLeftButtonDown +=
        new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown );
}

protected override void OnDetaching()
{
    base.OnDetaching();
    this.AssociatedObject.MouseLeftButtonDown -=
        new MouseButtonEventHandler( AssociatedObject_MouseLeftButtonDown );



Read more: Silverlight Show
QR: Behaviors-and-Triggers-in-Silverlight-3.aspx

Sort C# Code Structure In Visual Studio 2010 With CodeSorter

code-sorter-2.png

One of the most tiring task you might have to perform over source code files everyday is code sorting. Since there aren’t any set conditions which one can instantly apply over source code file to make it look tidy and clean, users have to manually sort the code structure according to their requirements. If you’re looking for a relatively easy way to sort your C# code in Visual Studio 2010, you can try out CodeSorter to specify code sorting conditions, so that they can be applied with a single click over all the code files. The add-in only works with C# project files and may disturb code structure of other languages. The add-in has a host of different code sorting conditions which can be customized in numerous ways. It was developed to sort source code files by different conditions such as, names, types; including, class, struct, method, virtual modifiers; virtual overide, new, etc.
It adds two code sorting options in Tools menu – Sort Code and Sort All Files in Project. The Sort Code option sorts code structure of only currently open file whereas the latter option sorts all the files present in your project. Before sorting out code, you need to configure the code sorting conditions. Open Code Sorter Options from Tools menu.


Read more: Addictive tips
QR: https://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://www.addictivetips.com/windows-tips/sort-c-sharp-code-structure-in-visual-studio-2010-with-codesorter/