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

CryptoAPI and 5 bytes exponent public keys

| Thursday, July 29, 2010
One customer of mine wanted to import a public key he got from a partner. That public key had a 2048 bits modulus and a 5 bytes exponent.

The problem was that CryptoAPI's RSAPUBKEY structure doesn't allow a 5 bytes exponent because it defines the public exponent with a DWORD (4 bytes max):

typedef struct _RSAPUBKEY {
DWORD               magic ;
DWORD               bitlen ;
DWORD               pubexp ;
} RSAPUBKEY;

CryptoAPI only supports 4 byte exponents with MS CSPs (Cryptographic Service Providers). CNG overcomes this limitation on Vista and later:

Key Storage and Retrieval
"
CNG is more flexible with regard to RSA key pairs. For example, CNG supports public exponents larger than 32-bits in length, and it supports keys in which p and q are different lengths.
"

Please, note that the restriction of 4 byte exponents are for MS CSPs only. CryptoAPI should be able to work with 5 byte exponents if using a third-party CSP.

Read more: Decrypt my World

Posted via email from .NET Info

Database internal file versions– How to determine if the database was upgraded or created from scratch

|
In some cases it it interesting to know whether a database was directly created on the current version of the running SQL Server instance or if the database was upgraded during an upgrade of the instance or by attaching a database from an older version to a newer version of SQL Server.

The information is stored in the datafile headers. To reveal it you will have to use the DBCC command and redirect the information to the trace output (by default this will be send to the errorlog) by using the following command:

DBCC TRACEON(3604)

After that you free to use one of the following commands:

DBCC DBINFO (information of the current database you are executing from)
DBCC PAGE(‘YourDatabaseHere’1,9,3) (Whereas “YourDatabaseHere’1” is you database to check for)
to will get you the following information:

1346.clip_5F00_image002_5F00_thumb.jpg

Read more: Developer hearted / Relational minded

Posted via email from .NET Info

How to request an smartcard logon cert programmatically (C#)

|
Hi all,

The other day I created this C# sample which shows how to request an smartcard logon cert to a CA. It is based on this other sample: How to create a certificate request with CertEnroll and .NET (C#).

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

//  Add the CertEnroll namespace
using CERTENROLLLib;
using CERTCLIENTLib;

namespace CATest
{
   public partial class Form1 : Form
   {
       private const int CC_DEFAULTCONFIG = 0;
       private const int CC_UIPICKCONFIG = 0x1;
       private const int CR_IN_BASE64 = 0x1;
       private const int CR_IN_FORMATANY = 0;
       private const int CR_IN_PKCS10 = 0x100;
       private const int CR_DISP_ISSUED = 0x3;
       private const int CR_DISP_UNDER_SUBMISSION = 0x5;
       private const int CR_OUT_BASE64 = 0x1;
       private const int CR_OUT_CHAIN = 0x100;

       public Form1()
       {
           InitializeComponent();
       }

       // Create request
       private void createRequestButton_Click(object sender, EventArgs e)
       {
           //  Create all the objects that will be required
           CX509CertificateRequestPkcs10 objPkcs10 = new CX509CertificateRequestPkcs10Class();
           CX509PrivateKey objPrivateKey = new CX509PrivateKeyClass();
           CCspInformations objCSPs = new CCspInformationsClass();
           CX500DistinguishedName objDN = new CX500DistinguishedNameClass();
           CX509Enrollment objEnroll = new CX509EnrollmentClass();
           CObjectIds objObjectIds = new CObjectIdsClass();
           CObjectId objObjectId = new CObjectIdClass();
           CX509ExtensionKeyUsage objExtensionKeyUsage = new CX509ExtensionKeyUsageClass();
           CX509ExtensionEnhancedKeyUsage objX509ExtensionEnhancedKeyUsage = new CX509ExtensionEnhancedKeyUsageClass();
           CX509ExtensionTemplateName objExtensionTemplate = new CX509ExtensionTemplateName();
           string strRequest;

           try
           {
               requestText.Text = "";

Read more: Decrypt my World

Posted via email from .NET Info

Silverlight and WebSockets

|
I was intrigued by this post from Tomek which has links to a prototype of an application built with Silverlight but using WebSockets.

It’s kind of interesting because running the application in IE9 gives me;

image_thumb.png

because Chrome has support for WebSockets already and so the sample switches out the Silverlight functionality.

If you’ve not read about WebSockets then there’s a starter here and info on the protocol up here.

If you’ve programmed with connected, TCP sockets then you know that the model is essentially;

Server listens. Client connects.
Connection stays open during lifetime of communication.
Client and Server send stuff any time they like in a full-duplex manner.
So, traditional sockets are great in that they allow full duplex comms such as when the server wants to notify the client that something has happened but they’re not so great in that they require an open connection which tends to limit your server side scalability. They’re also not so great when it comes to crossing boundaries that only allow HTTP on port 80 or 443.

If you’ve programmed with HTTP then you know that the model is essentially;

Server listens. Client connects.
Client sends request.
Server sends response.
Client (generally) disconnects as soon as that response comes back.
and so HTTP is a great use of sockets in that it makes the model a lot more scalable by not requiring a permanent connection between the client and the server and server-side state but, because of that lack of connection, you can’t have the server notify the client of something because, generally, the client and server have no connection at any particular point in time.

Now, of course you can use HTTP in various ways to try and give the illusion that the server does have a connection to the client and that’s normally done by just having the client poll the server on some period essentially asking “Do you have anything for me right now?” with the expectation that the answer from the server will frequently be “no”.

So, a server wanting to “notify” a client simply has to put its notification data into a database and wait for the next time that client polls when it will be able to deliver the notification.


Read more: Mike Taulty's Blog

Posted via email from .NET Info

Sidebar that Silverlight - VB Project Template to help build Silverlight based Windows Sidebar Gadgets

|
There’s something about using Silverlight for a Sidebar gadget that appeals to me. Then there’s the fact that, with Win7’s success, sidebar gadgets are now getting more usage. And finally there’s the general uptick happening with Silverlight itself.  So we mash all these together and get…?

Yes, there’s also a C# template too, Silverlight Sidebar Gadget (C#)

Read more: Greg's Cool [Insert Clever Name] of the Day
Read more: C# Template

Posted via email from .NET Info

How to compile OpenJDK on Ubuntu

|
OpenJDK Overview
OpenJDK is the open source implementation of Java. OpenJDK is under version control by a distributed version control system called Mercurial . This guide will describe how to install Mercurial, download the source code of OpenJDK and how to compile OpenJDK.

Install Mercurial and Extensions
You first need to make sure Mercurial is installed on your system.

sudo apt-get install mercurial

In addition to standard Mercurial you also need the Forest Extension. These are currently not packages for Ubuntu, see Bug report

You can get the forest extension via the following command. This will create the directory hgforest with the file "forest.py".

# close the forest extensions
# if the url below does not work you find alternative url via
# http://bitbucket.org/repo/all?name=hgforest
hg clone https://vogella@bitbucket.org/vogella/hgforest-crew

Edit the file "~/.hgrc" (i.e. the mercurial configuration file) to include the lines.

[extensions]
forest=/home/vogella/hgforest/forest.py

After this change you should be able to use commands such as 'fclone' and 'fpull' is you type in "hg" in the command line.

Read more: Lars Vogel

Posted via email from .NET Info

Implementing a Basic Hello World WCF Service

|
Introduction

In this article, we will manually implement a basic WCF service from scratch, step by step with clear instructions and precise screen snapshots. You will have a thorough understanding of what WCF is under the hood after you read this article. Visual Studio 2010 under Windows 7 will be used for all screenshots of this article.

We will build the WCF service manually from scratch, meaning we will not use any Visual Studio 2010 template to create the service. We will also create the host application and the test client application manually, including generating the proxy and configuration files manually with the tool svcutils.exe. In your real project, you can and should utilize Visual Studio 2010 to help with these tasks, but manually doing the actual work is a great way for you to understand what WCF is really like under the hood. This will help you to better understand the why of those WCF templates within Visual Studio.

We will build a HelloWorld WCF service by carrying out the following steps:
• Create the solution and project
• Create the WCF service contract interface
• Implement the WCF service
• Host the WCF service in the ASP.NET Development Server
• Create a client application to consume this WCF service

Creating the HelloWorld solution and project

Before we can build the WCF service, we need to create a solution for our service projects. We also need a directory in which to save all the files. Throughout this book, we will save our project source codes in the C:\SOAwithWCFandLINQ\Projects directory. We will have a subfolder for each solution we create, and under this solution folder, we will have one subfolder for each project.

Read more: Codeproject

Posted via email from .NET Info

EventbasedPipelineSystem

|
The project implements a framework for event-based method pipelines with easy to use multi-threading support.
It's developed in C#/.Net Framework.

Read more: Codeplex

Posted via email from .NET Info

Microsoft XAML Toolkit CTP - July 2010

|
The XAML Toolkit bits are available here.  (actually soon to be posted  -- Brian)

Overview

Features of the XAML Toolkit

XamlDom – A XAML DOM that is LINQ friendly.  Enables easy static analysis.
XAML FxCop integration – You can run FxCop rules that analyze your XAML against rules.
XAML FxCop rule authoring - A BaseXamlRule implementation that allows you to write custom FxCop rules that target XAML.  We’re also shipping a couple of simple ones including a ValidationRule that will validate your XAML.
SilverlightSchemaContext – A XamlSchemaContext that allows System.Xaml to parse Silverlight XAML for tools use.
What’s New in the XAML Toolkit CTP – July 2010

The UISchemaContext has been removed.
The SilverlightSchemaContext now supports Silverlight Version 3.0, 4.0 and Phone 7.
A SilverlightAssemblyHelper static class has been added to help with loading the correct Silverlight schema version.

Read more: The official blog of the Windows Presentation Foundation Team

Posted via email from .NET Info

State in asp.net

|
היכן ניתן לשמור מידע בעולם ה - web.

כידוע לכל מפתח WEB מתחיל - עולם ה - WEB הינו state less כלומר לפי ההגדרה אתר לא אמור לשמור מידע על המשתמשים בו, למרות זאת הרבה פעמים אנחנו צריכים לשמור מידע.

בפוסט הזה נסכם את האופציות.

צד הלקוח.

עוגיות - עוגיות הם אחד מהאופציות הישנות והטובות לשמירת מידע, היתרון הגדול שלהם הם שניתן לשמור בהם מידע לאורך זמן החיסרון הגדול שלהם שהם נשלחים בכל בקשה לשרת, ניתן לקרוא עוד כאן .

hidden filed - ככל האלמנטים מסוג input הערכים שבהם נשלחים לשרת ולכן אפשר לשמור בו מידע מבלי שהמשתמש יראה, כמובן שאחרי מעבר לדף אחר מאבדים את הערכים.

query string - מאוד דומה ל - hidden field אך הרבה יותר נפוץ ובדרך כלל נשמור בו מעט מידע שיגידו לדף מה לעשות ואיך לטעון את העמוד.

View State - סוג של hidden filed שיודע לקבל כל אובייקט שאפשר לעשות לו סירלזיצייה - היתרון שלו שנקבל בצד השרת את האובייקט ולא מחרוזת.

IE8 DOM Storage - יכולת חדשה של IE8 לשמור מידע בצד הלקוח. לקריאה נוספת

צד השרת

static - משתנים סטטים נשמרים ברמת האפליקצייה ולכן ניתן לשמור בהם מידע כל עוד שהאפליקצייה תהיה בחיים

Application - אותו דבר כמו static רק שהוא Dictionary שה - key הוא מחרוזת וה - value הינו כל אובייקט. (ברירת מחדל בזיכרון שעתיים)

Session אותו דבר כמו application רק שנשמר ברמת המשתמש (ברירת מחדל בזיכרון 20 דקות)

Cache - אותו דבר כמו Application אבל נותן את היכולת לקבוע זמן ריענון או להיות תלוי בקובץ (האם היה שינוי) או בבסיס נתונים.

Output Cache - נותן את היכלות לשמור פלט של html כדי שלא יצטרכו לייצר את כל הדף מחדש - כלומר אם נחליט לשמור את הדף ב - output cache למשך 20 דקות, הראשון שיגיע לעמוד יפעיל את ה - page load וכל שאר האירועים ובמשך 20 דקות כל המשתמשים שיגיעו לעמוד יקבלו את אותו פלט של html שהמשתמש הראשון קבל מתוך הזיכרון של השרת.

Context.Items - שומר את הערכים למשך ה - Request הנוכחי.

Read more: שלמה גולדברג (הרב דוטנט) Part 1, Part 2

Posted via email from .NET Info

The Most Powerful and Feature Rich Web-Based Code Editors (IDEs)

| Wednesday, July 28, 2010
   With all the talk of Cloud computing at the moment and after reading a short article on Dzones blog a few months back that questioned whether or not It Was the Right Time for Web-Based IDEs? (it was a split poll), we were inspired enough to venture out and find out what web based IDEs (integrated development environment) are available and which actually are the best. The results were a little bit surprising.

   What we found was literally hundreds upon hundreds of different web based editors, tools and generators for every possible language you could think of. The problem was that very few met with the criteria of being the powerful and feature rich IDE we were looking for. A lot of these tools had either not been updated in years or did they pack enough features to be deemed useful or functional in the grander scale. Other tools, look like they may have potential, but development has disappointingly slowed down.
As you may have guessed there have been many attempts at browser based IDE’s over the past few years, so what we have compiled for this article is a selection of IDEs that are not only functional, polished and professional, but are also ready to take the next big step and be the best web based code editing solution. Here is our favorite selection of web-based IDEs:

Reader Opinion: What do you think? Are you ready to take the step and use a web based IDE?

CodeRun – A free, Cross-Platform Browser-Based IDE

web_based_editor_01.jpg

CodeRun – A free, Cross-Platform Browser-Based IDE is a free and open-source web based IDE, which features native support for C#/.NET (3.5), PHP (5.1), JavaScript, HTML and CSS. C# support includes ASP.NET, WCF, Silverlight and WPF browser application development and deployment. Database support includes SQL Server 2005 and Amazon SimpleDB.
Syntax coloring and code completion are featured to help you during development. It also features an online debugger that allows you to set breakpoints, step through your code, inspect call stack, and other debugging actions.


Bespin
From Mozilla Labs, Bespin aims to be a ‘top-of-the-line text editor that lives in your browser’. It is based on the latest web standards and does require a “modern browser” with support for HTML5 and specifically the Canvas element with the ability to draw text.
Depending on what you’re trying to accomplish and how much time you’re willing to invest, there are several ways in which you can use Bespin: You can try the IDE directly (Bespin demo), download Bespin Embedded for use in your own applications or you can setup your own Bespin server (not for the faint of heart!).


Read more: speckyboy

Posted via email from .NET Info

Profiling an application with Visual Studio – Memory allocation

|
I discussed the possibilities of CPU sampling and instrumentation data collection in the previous articles and now it is time to benchmark the application performance indicators that target the memory.

To test this feature out, I created another sample application. This time, it works with files and I tried to create a simulation of a memory-consuming process.

The setup
It is a simple C# Console Application with only one method – Main. All the code is executed inside that method and no calls to external libraries are made. Here is what it looks like:

using System;
using System.IO;

namespace ConsoleApplication
{
   class Program
   {
       static void Main(string[] args)
       {
           string[] fileList = Directory.GetFiles(@"D:\Temporary");

           foreach (string file in fileList)
           {
               Console.WriteLine("Getting bytes for " + file + "...");
               Console.WriteLine("Bytes for " + file + ": " + File.ReadAllBytes(file).Length);
           }

           Console.Read();
       }
   }
}

What this code does is it gets the file paths (given a specific source folder) and then reads the file contents for each file separately to a byte array. For large files, this process will allocate quite a bit of memory, so that is a perfect way to demonstrate the capacities of built in profiling tools when it comes to memory allocation benchmarking.

As you can see from the code I am showing here, I am referencing a path that points to a folder called Temporary. To test it out, I copied a set of small and not so small files over there (a bunch of large texture files and a movie). And that is pretty much everything that is needed to simulate intensive memory consumption.

Trying it out – getting and analyzing the results
To start the process, go to Analyze > Launch Performance Wizard and select .NET Memory Allocation (Sampling)

Read more: DZone

Posted via email from .NET Info

Deploying Microsoft RemoteFX for Personal Virtual Desktops Step-by-Step Guide

|
This step-by-step guide walks you through the process of setting up a working personal virtual desktop that uses RemoteFX in a test environment. Upon completion of this step-by-step guide, you will have a personal virtual desktop with RemoteFX assigned to a user account that can connect by using RD Web Access. You can then test and verify this functionality by connecting to the personal virtual desktop from RD Web Access as a standard user.

Read more: MS Download

Posted via email from .NET Info

Bitlocker PIN Tool

|
Deploying Bitlocker with Windows 7 in enterprise environments works pretty nice with the new features which have beend implemented by microsoft. There's still one big problem to solve. Users can't change their PBA Bitlocker PIN without administrative priviledges.

Read more: Codeplex

Posted via email from .NET Info

ASP.NET MVC 3 Preview 1 Released – Channel 9 Video and Hanselminutes Podcast 224, Oh My!

|
Phil and friends released ASP.NET MVC 3 Preview 1 today. I snuck into the office of Phil Haack and Morgan the Canadian Intern to talk about the release of ASP.NET MVC 3 Preview 1 and some of the cool "futures" stuff that Morgan (and our fleet of interns) is working on. This video isn't only about MVC as Morgan's working on some cool CSS Sprites stuff that works nicely in WebForms that you should check out as well.

Also, my two-hundred-and-twenty-fourth podcast is up and I talk more in depth with, yes, you guessed, it, Phil Haack. More detail in a less shaky-camera format.

What's new in ASP.NET MVC 3?

Note that installing ASP.NET MVC 3 won't mess up your ASP.NET MVC 2 applications.

Razor Syntax View Engine - Cleaner view syntax
Dynamic View and ViewModel properties - passing data between controllers and views using dynamic rather than a dictionary
"Add View" Dialog Box Supports Multiple View Engines - You two can be in this box.
Service Location and Dependency Injection Support - Get your DI hooked into controller factories, dependency injection, action filters and View Pages.
Global Filters - put filters on the all control methods
New JsonValueProviderFactory Class - Model bind directly to JSON-encoded data
Support for .NET Framework 4 Validation Attributes and IValidatableObject - Easier validation including validating one property based on another.
New IClientValidatable Interface - Discovering at runtime if the client supports validation.
Support for .NET Framework 4 Metadata Attributes - Support .NET 4 specific attributes like DisplayAttribute
New IMetadataAware Interface - Write your own attributes to contribute to the ModelMetadata creation process.
New Action Result Types - HttpNotFoundResult, HttpStatusCodeResult.
Permanent Redirect - More easily return 301s for Actions, Routes or any URL.

Read more: Scott Hanselman

Posted via email from .NET Info

How to make AJAX-requests to ASP.NET MVC application using jQuery

|
I decided to write over long time one posting that is directed to beginners who start with jQuery and AJAX. One of the first things to study is how to make requests to server and how to retrieve objects. In this posting I will show you how to use jQuery to retrieve JSON data from ASP.NET MVC application and how to debug it.

Making AJAX-requests to server
This was one of first things I needed when I started with jQuery. If you are working on ASP.NET MVC there are some tricks but I tell about these later. Now let’s see how to make AJAX-request to server.

var url = '/contacts/ListPartiesByNameStart?nameStart=A';
$.ajax({ url: url, success: DataRetrieved, type: 'POST', dataType: 'json' });

Should be simple but let me still explain a little bit.

url – this is the URL where request is sent. In my case there is controller called contacts and it has action calles ListPartiesByNameStart(). This action method takes  parameter nameStart (first letter of person or company).
success – this is the JavaScript function that handles retrieved data. You can write there also anonymous function but I suggest you to use functions with names because otherwise your code may get messy when functions grow.
type – this is the type of request. It is either GET or POST. I suggest you to use POST because GET requests in JSON format are forbidden by ASP.NET MVC by default (I will show you later how to turn on GET requests to JSON returning actions).
dataType – this is the data format that is expected to be returned by server. If you don’t assign it to value then returned result is handled as string. If you set it to json then jQuery constructs you JavaScript object tree that corresponds to JSON retrieved from server.
If you are using POST requests then I suggest you to use parameter called data that is serialized as POST body. You can find more information about parameters from jQuery ajax() method documentation. And here you can find jQuery API documentation.

Here is the example of DataRetrieved function where I expected that server returned person object in JSON format.

function DataRetrieved(data) {
   // Do something with data
   alert(data.FirstName + ' ' + data.LastName);
}

Read more: DZone

Posted via email from .NET Info

Introducing “Razor” – a new view engine for ASP.NET

|
AddView9_thumb_6A5950A4.png

One of the things my team has been working on has been a new view engine option for ASP.NET.

ASP.NET MVC has always supported the concept of “view engines” – which are the pluggable modules that implement different template syntax options.  The “default” view engine for ASP.NET MVC today uses the same .aspx/.ascx/.master file templates as ASP.NET Web Forms.  Other popular ASP.NET MVC view engines used today include Spark and NHaml.

The new view-engine option we’ve been working on is optimized around HTML generation using a code-focused templating approach. The codename for this new view engine is “Razor”, and we’ll be shipping the first public beta of it shortly.

Design Goals

We had several design goals in mind as we prototyped and evaluated “Razor”:

Compact, Expressive, and Fluid: Razor minimizes the number of characters and keystrokes required in a file, and enables a fast, fluid coding workflow. Unlike most template syntaxes, you do not need to interrupt your coding to explicitly denote server blocks within your HTML. The parser is smart enough to infer this from your code. This enables a really compact and expressive syntax which is clean, fast and fun to type.

Easy to Learn: Razor is easy to learn and enables you to quickly be productive with a minimum of concepts. You use all your existing language and HTML skills.

Is not a new language: We consciously chose not to create a new imperative language with Razor. Instead we wanted to enable developers to use their existing C#/VB (or other) language skills with Razor, and deliver a template markup syntax that enables an awesome HTML construction workflow with your language of choice.

Works with any Text Editor: Razor doesn’t require a specific tool and enables you to be productive in any plain old text editor (notepad works great).

Has great Intellisense: While Razor has been designed to not require a specific tool or code editor, it will have awesome statement completion support within Visual Studio. We’ll be updating Visual Studio 2010 and Visual Web Developer 2010 to have full editor intellisense for it.

Unit Testable: The new view engine implementation will support the ability to unit test views (without requiring a controller or web-server, and can be hosted in any unit test project – no special app-domain required).

We’ve spent the last few months building applications with it and doing lots of usability studies of it with a variety of volunteers (including several groups of non-.NET web developers). The feedback so far from people using it has been really great.

Choice and Flexibility

One of the best things about ASP.NET is that most things in it are pluggable. If you find something doesn’t work the way you want it to, you can swap it out for something else.

The next release of ASP.NET MVC will include a new “Add->View” dialog that makes it easy for you to choose the syntax you want to use when you create a new view template file.  It will allow you to easily select any of of the available view engines you have installed on your machine – giving you the choice to use whichever view approach feels most natural to you

Read more: ScottGu's Blog

Posted via email from .NET Info

Can You Run Unit Tests With Out Installing Visual Studio?

|
A customer asked me this question today, the answer is YES. Unit Tests are not used only to test code, you will need to use Unit Tests to test WCF for example. Running Unit Tests on machines with no installation of Visual Studio is an ability that can save licenses and installations.

So how it is done?

All you need is a Test Agent installed on the target machine, from this point you can do it in a few ways:

  • Using command line and running all the tests by using the MSTest.exe
  • Using the Visual Studio installed on another computer and change the test settings to run tests on the target machine.

Read more: Eran Ruso

Posted via email from .NET Info

ASP.NET MVC: Adding client-side validation to ValidatePasswordLengthAttribute

|
When you create a new ASP.NET MVC 2 project in Visual Studio there are a number of files that are created. One of these is AccountModel.cs. If we ignore the fact that this one file contains multiple classes (I’ve no idea why!), we will see that there is some nice example code lurking in there. One such piece of code is the ValidatePasswordLengthAttribute. This attribute can be applied to your model to enforce a minimum password length (based on the minimum specified by the currently configured MembershipProvider). The code below shows the attribute usage (taken from ChangePasswordModel):

       [Required]
       [ValidatePasswordLength]
       [DataType(DataType.Password)]
       [DisplayName("New password")]
       public string NewPassword { get; set; }

This lets us take advantage of the model binding and validation that is baked into ASP.NET MVC 2. One nice feature of the validation is that the built in validators make it very easy to enable client-side validation by adding the following line to your view:

<% Html.EnableClientValidation(); %>

With this in place, ASP.NET MVC will emit the necessary javascript to wire up the client-side validators (you need to reference the script files from your view). Scott Guthrie has a good blog post that goes through the in-built validation in more depth – the remainder of this post will look at adding creating your own custom client-side validation.

If you enable client-side validation for the ChangePassword view (the snippet above) then you will find that the required field validation is triggered in the browser but the minimum length validation only happens on a postback. This is because the in-built Required validator has client-side support, but the ValidatePasswordLength supplied as part of the template doesn’t.

So, how do you go about adding client-side validation? That’s what the rest of this post will cover.

Read more: Stuart Leeks

Posted via email from .NET Info

Abandoned Adobe Version Cue Users Rapidly Moving to Subversion

|
Creative Professionals Find Subversion Delivers Exactly What They Need to Store and Manage Graphics and Animation Files

San Ramon, CA July 27, 2010 – WANdisco, the makers of Enterprise Subversion with the most active core developers from the project on staff, today announced that a number of organizations stranded by Adobe’s decision to abandon Version Cue in CS5 are finding that Subversion makes an excellent replacement. In addition to being free, as well as easy to install and use, these organizations are also finding that Subversion solves a number of issues they had with Version Cue.

“We downloaded Subversion with the latest TortoiseSVN client on Windows from WANdisco,” said Ian Calhaem, Technical Director at Forensic Imaging, Ltd, an Auckland, New Zealand based graphics consulting firm. “In addition to being easy for us to install and use, the software has already proved its value in overcoming a problem we faced with CS3 files crashing in CS5. Subversion makes it very simple to return to the original file and try again.”

Another problem Version Cue users faced was the lack of file locking in some versions of Adobe’s popular Indesign graphics package, resulting in data loss, “Adobe recently acknowledged the potential for data loss in some versions of Indesign, due to a lack of file locking,” said Calhaem. “Subversion, doesn’t normally need file locking, but it’s available as an option so Subversion solves this problem as well.”

Read more: WAN Disco

Posted via email from .NET Info

Silverlight HTML5 WebSocket client with an HTML bridge to Ajax/JavaScript

|
As part of our ongoing experimentation with the HTML5 WebSocket proposed standard for duplex communication between web browsers and servers, we have prototyped a WebSocket protocol implementation based on Microsoft technologies. The prototype consists of a WCF service and a Silverlight client with an HTML bridge to JavaScript implemented in jQuery. You can read more about it at http://tomasz.janczuk.org/2010/07/silverlight-html5-websocket-client-with.html. You can also check out a sample web chat application based on the prototype at http://40interop.epiq.msftlabs.com/html5/wsdemo.html.

Read more: The .NET Endpoint

Posted via email from .NET Info

Vulnerability Note VU#940193

|
Microsoft Windows automatically executes code specified in shortcut files

Overview

Microsoft Windows automatically executes code specified in shortcut (LNK and PIF) files.
I. Description

Microsoft Windows supports the use of shortcut or LNK files. A LNK file is a reference to a local file. A PIF file is a shortcut to a MS-DOS application. Clicking on a LNK or PIF file has essentially the same outcome as clicking on the file that is specified as the shortcut target. For example, clicking a shortcut to calc.exe will launch calc.exe, and clicking a shortcut to readme.txt will open readme.txt with the associated application for handling text files.
Microsoft Windows fails to safely obtain icons for shortcut files. When Windows displays Control Panel items, it will initialize each object for the purpose of providing dynamic icon functionality. This means that a Control Panel applet will execute code when the icon is displayed in Windows. Through use of a shortcut file, an attacker can specify a malicious DLL that is to be processed within the context of the Windows Control Panel, which will result in arbitrary code execution. The specified code may reside on a USB drive, local or remote filesystem, a CD-ROM, or other locations. Viewing the location of a shortcut file with Windows Explorer is sufficient to trigger the vulnerability. By default, Microsoft Windows has AutoRun/AutoPlay features enabled. These features can cause Windows to automatically open Windows Explorer when a removable drive, such as a USB thumb drive, is connected. Other applications that display file icons can be used as an attack vector for this vulnerability as well. When used in conjunction with a WebDav resource, Internet Explorer can be used as an attack vector for this vulnerability. With the case of Internet Explorer, no user interaction beyond viewing a web page is required to trigger the vulnerability.

This vulnerability is being exploited in the wild to spread malware that targets control systems. Exploit code for this vulnerability is publicly available.

II. Impact

By convincing a user to display a specially-crafted shortcut file, an attacker may be able to execute arbitrary code with the privileges of the user. Depending on the operating system and AutoRun/AutoPlay configuration, this can happen automatically by connecting a USB device. This vulnerability can also be triggered by viewing a web page with Internet Explorer or opening a document with Microsoft Office.

Read more: US-Cert

Posted via email from .NET Info

New gov't rules allow unapproved iPhone apps

| Tuesday, July 27, 2010

WASHINGTON – Owners of the iPhone will be able to legally unlock their devices so they can run software applications that haven't been approved by Apple Inc., according to new government rules announced Monday.

The decision to allow the practice commonly known as "jailbreaking" is one of a handful of new exemptions from a 1998 federal law that prohibits people from bypassing technical measures that companies put on their products to prevent unauthorized use of copyright-protected material. The Library of Congress, which oversees the Copyright Office, reviews and authorizes exemptions every three years to ensure that the law does not prevent certain non-infringing uses of copyright-protected works.

For iPhone jailbreakers, the new rules effectively legitimize a practice that has been operating in a legal gray area by exempting it from liability. Apple claims that jailbreaking is an unauthorized modification of its software.

Mario Ciabarra, founder of Rock Your Phone, which calls itself an "independent iPhone application store," said the rules mark the first step toward opening the iPhone app market to competition and removing the "handcuffs" that Apple imposes on developers that want to reach users of the wildly popular device.

Unless users unlock their handsets, they can only download apps from Apple's iTunes store. Software developers must get such apps pre-approved by Apple, which sometimes demands changes or rejects programs for what developers say are vague reasons.

Ciabarra noted that Google Inc. has taken a different approach with its Android operating system, which is emerging as the biggest competitor to the iPhone. Google allows users of Android phones to download applications from outside the Android Market.

Read more: Yahoo

Posted via email from .NET Info

AutoIt v3

|
AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.

Features:

Easy to learn BASIC-like syntax
Simulate keystrokes and mouse movements
Manipulate windows and processes
Interact with all standard windows controls
Scripts can be compiled into standalone executables
Create Graphical User Interfaces (GUIs)
COM support
Regular expressions
Directly call external DLL and Windows API functions
Scriptable RunAs functions
Detailed helpfile and large community-based support forums
Compatible with Windows 95 / 98 / ME / NT4 / 2000 / XP / 2003 / Vista / 2008
Unicode and x64 support
Digitally signed for peace of mind
Works with Windows Vista's User Account Control (UAC)
AutoIt has been designed to be as small as possible and stand-alone with no external .dll files or registry entries required making it safe to use on Servers. Scripts can be compiled into stand-alone executables with Aut2Exe.

Read more: AutoIt

Posted via email from .NET Info

Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication

|
This guide presents a practical, scenario driven approach to designing and building secure ASP.NET applications for Windows 2000 and version 1.0 of the .NET Framework. It focuses on the key elements of authentication, authorization, and secure communication within and across the tiers of distributed .NET Web applications. (This roadmap: 6 printed pages; the entire guide: 608 printed pages)

Read more: MSDN

Posted via email from .NET Info

How to use the MSBuild debugger in Visual Studio 2010

|
Dan Moseley, dev lead for msbuild, wrote a debugger for msbuild while on leave(!) back during the 2010 cycle.  While it ultimately couldn’t be fully completed and tested to be an official feature, it is in the product with a switch to enable it (it’s off by default).  This was a conscious decision made by the VS team, and I think it was a great compromise.  It wasn’t something feasible as a power tool, and it’s too useful to have to wait for the next release.

Dan has written a series of blog posts on how to use it.

Read more: Buck Hodges
Read more: Debugging MSBuild script with Visual Studio, Debugging MSBuild script with Visual Studio (2), Debugging MSBuild script with Visual Studio (3)

Posted via email from .NET Info

Arkanoid in Windows Phone 7 using XNA

|
Prof. Kostas Anagnostou from Ionian University has created an excellent 6 part tutorial covering the creation of the classic Arkanoid game for the PC using XNA framework. Here are the links for the tutorial

Permanent link to Δημιουργώντας το Arkanoid μέρος 1ο
Permanent link to Arkanoid μέρος 2ο
Permanent link to Arkanoid- Game State Management
Permanent link to Arkanoid- Game State Management μέρος 2ο
Permanent link to Arkanoid- Σχεδιασμός πίστας
Permanent link to Arkanoid- Game over!
You can also find the complete tutorial packaged in a pdf document in StudentGuru e-learning page. All the tutorials are written in Greek but you can certainly use a translation platform such as Microsoft Translator to read them.

Reminder: You can download tools for creating Windows Phone applications (Silverlight) and games (XNA) for free by visiting http://developer.windowsphone.com
Given his kind permission, I decided to port the game to Windows Phone 7. I have to admit that porting was rather easy, given the fact that XNA framework has minor differences comparing PC/XBOX engine to Windows Phone. Initially, something that one has to pay attention to is the screen sizes. In Windows, the screen size (resolution) is the one the user has chosen. In Windows Phone 7, it’s 800 x 480. You can see it in the code Visual Studio creates for you

// Pre-autoscale settings.
graphics.PreferredBackBufferWidth = 480;
graphics.PreferredBackBufferHeight = 800;

The other thing I had to change in order for this to work in Windows Phone 7 was the player input. In the PC, you have the keyboard. In Windows Phone 7, you have a touch screen. One can easily “query” the touch screen for input using this simple line of code

TouchCollection tc = TouchPanel.GetState();

In this way, you get a collection of TouchLocation objects, with each one representing the point where the user touched the screen. So, we can query this collection and get information about each and every one point that the user touched the screen (hint: Windows Phone 7 devices will have capacitive 4-point multitouch screens).

We are using the following code inside the UpdateWorld method (which gets called by the Update XNA method) to determine the paddle’s movement and placement

paddleSpeed = 10;
TouchCollection tc = TouchPanel.GetState();
if (tc.Count != 0)
{
           TouchLocation tl = tc[0];

           int distance = (int)tl.Position.X - (int)(paddle.X + paddle.Width / 2);

           paddleSpeed *= Math.Sign(distance);

           if (Math.Sign(distance) == previousPaddleDirectionSign)
           {
                   paddleSpeed += Math.Sign(distance) * 5;
           }
           previousPaddleDirectionSign = (short)Math.Sign(distance);
               
           if (Math.Abs(distance) >= 3)
                  paddle.X += paddleSpeed;
}

OK, let’s decrypt it a bit. For starters, we initialize the variable paddleSpeed to 10. 10 pixels will be the minimum movement of the paddle, either left or right. Then, we get the collection of touch points, getting a reference to the first touch point (we assume that the user won’t touch the screen in more than one point. If he does, we ignore them). We declare a distance variable, which value is set to be equal to the difference between touch point’s X and the center X of the paddle (paddle.X + paddle.Width / 2). Consequently, if the user touches righter than the paddle’s center, distance will be a positive integer. Otherwise, it will be negative.

Read more: Scenes From A Developer Memory

Posted via email from .NET Info

Principles 1: The Essence of Driving – A Crash Course in Project Management

|
About a year ago, I got feedback from my team that I needed to clarify what I meant by “drive this effort” or “lead that effort”. So I decided to create a quick document explaining what I meant. Below is that document. I later converted the document to a slide-deck, which I will publish shortly too.

There are *a lot* of books on project management. From that point of view, there is nothing special about the techniques below – all of them are pretty much common sense and all of them can be found in those books. What is special about the post that follows is the condensed presentation (my goal is to essentially save you from reading a PMP book) and the fact that we actually used every single one of these techniques to manage the WPF 4 and Visual Studio 2010 products, which we released in April 2010.

The techniques listed below are:

Over-communication
Scorecard
Trend (and glide-path)
Backlog / Burn-down List
“Branded” status emails
Schedule in Excel
Schedule in Visio
Enjoy!

+++

General Notes
Project management is a skill that can (as any other skill) be acquired and improved. Really most of our work and a significant part of our personal lives boil down in one way or another to project management.

Every project has a life-cycle, consisting of several standard phases:

Initiating
Planning and kick-off
Executing
Monitoring & Controlling
Closing
Post-mortem learning
An effective PM[1] understands and actively manages the life-cycle of a project.

The Meaning of “Drive This”
When I ask somebody to “drive” this or that, what I really mean is “be an effective PM of this effort”, exhibiting the following:

Independence and accountability
Ability to construct, communicate and get approval for a clear and well-though-out plan for the project, including:
Timelines
Scope, goals / non-goals and success criteria
Internal and external “unmovables” and requirements
Stakeholders
Costs and funding
Risks and mitigations
Ability to set the project in motion, keep the project in motion and close down the project
Proactive contribution of directive energy to the project, creating excitement, and identifying and removing road-blocks.
Active monitoring of the progress of the project
Proactive communication of status
Ability to reach the desired results


Read more: Ivo Manolov's Blog

Posted via email from .NET Info

"Facebook C# SDK" Announced for Microsoft Visual Studio Developers

|
Facebook engineer, Andrey Goder, announced the alpha release of the Hackathon Facebook C# SDK project for Visual Studio Developers (requires Microsoft's free Visual C# 2010 Express Edition).
Facebook C# SDK Features:

Works with both Web (ASP.NET) and desktop applications.
Uses OAuth 2.0 for authentication.
Supports a convenient way of making calls to the new Graph API using the OAuth 2.0 access token.

Read more: Blake
Read more: Facebook C# SDK

Posted via email from .NET Info

Make The WebClient Class follow redirects and get Target Url

|
How to make the .NET WebClient class follow redirects and get the target url

Unlike its brother HttpWebRequest, the WebClient class automatically follows redirects, but if you need to get the "final" url, you'll need to "wrap" your WebClient in a class that derives from System.Net.WebClient. Here's an example:

using System;
using System.Net;

public class MyWebClient : WebClient
{

Uri _responseUri;

public Uri ResponseUri
{

get { return _responseUri; }
}

protected override WebResponse GetWebResponse(WebRequest request)
{

WebResponse response = null;
try
{
response = base.GetWebResponse(request);
_responseUri = response.ResponseUri;
}
catch
{
}

return response;
}
}


By overriding the GetWebResponse method, we can populate a ResponseUri property with the final target of any 302 rediirects. Redirects are very common in all kinds of websites as they allow the owner to count hits, and log information before sending you on your merry way to the target.

Here's some sample code that goes through a whole list of integer "Redirect Ids", assembles the page title and final url, and saves these to a delimited text file that can be read later:

static string urlbase="http://sitewithredirect.com/Redirect.aspx?id=";

static void ProcessUrls()
{

string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)";

for (int i =1; i < 4000; i++)
{

string item = i.ToString();
string url = urlbase + item;
string content = null;
string targetUrl = null;
string title = null;

MyWebClient w = new MyWebClient();

try
{
content = w.DownloadString(url);
targetUrl = w.ResponseUri.ToString();
Regex rex = new Regex(regex, RegexOptions.IgnoreCase);
title = rex.Match(content).Value.Trim();
System.Diagnostics.Debug.WriteLine(targetUrl);
}

Read more: eggcafe

Posted via email from .NET Info

Implementing the HTTP Request/Response Model inside of Silverlight

|
Introduction

Silverlight gives users the ability to create an extremely rich UI experience for the user, but what about the server?  How can I take advantage of Silverlight to do simple access to a server whether it's a LINUX Web Server or a Windows Web Server?  What if I want to make REST calls to my server?  Silverlight includes a few namespaces for doing simple request and response to and from the server:  System.Net and System.Net.Browser.  These assemblies contain the following classes that will allow us to talk to our server over the web:

Class Description
WebRequestCreator Allows us to create a web request given a URI
HttpWebRequest A web request in which we can set our request
HttpWebResponse The web response coming back from the server

With the help of just these three classes, we can do everything we need to do to push data from the Silverlight client to the web server and retrieve information from the web server into our Silverlight client.

The Client Access Policy

In order to have authorization to use Silverlight against the web server, the web server must have a client access policy file installed in the root.  Without this policy in place on the web server, Silverlight will continue to throw authorization exceptions anytime it tries to contact a server on another domain with the classes listed above.  Listing 1 shows a typical client access policy.  This policy allows all headers to go through on a request and allows requests from all domains.  It also allows you to use any of the http methods: GET, PUT, POST, and delete.  You can restrict any of the access by simply replacing the wildcard asterisk in each tag with a more specific value.  

Listing 1 - Typical Client Access Policy

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
 <cross-domain-access>
<!--Enables Silverlight 3 all methods functionality-->
   <policy>
     <allow-from http-methods="*" http-request-headers="*">          
       <domain uri="*"/>
     </allow-from>      
     <grant-to>      
       <resource path="/resources" include-subpaths="true"/>
     </grant-to>      
   </policy>
<!--Enables Silverlight 2 clients to continue to work normally -->
   <policy>
     <allow-from >      
       <domain uri="*"/>
     </allow-from>      
     <grant-to>      
       <resource path="/api" include-subpaths="true"/>
     </grant-to>      
   </policy>
 </cross-domain-access>
</access-policy>

Now  that we got that out of the way, we can do some real work on the client.  Let's start with a simple http GET method.  Everything done in Silverlight is asynchronous.  Initially the asynchronous world is a difficult planet to live on, but eventually you start to get the hang of residing on it and may even enjoy it.  To implement a GET we first create a web request and then call it.  The web request is created with the the convenient WebRequestCreator.  You can think of the WebRequestCreator as a factory that churns out HttpWebRequest objects.  Just feed it a uri and out spills a web request.  Keep in mind that you still need to populate the request with the methods, headers, and data.   Once you have your web request ready, just call the asynchronous BeginGetResponse and wait.  Listing 2 shows an example of creating the request and making the asynchronous call.

Read more: C# Corner

Posted via email from .NET Info

Silverlight On Mobile : 3D on your Windows Phone 7 with Silverlight

|
With my last “Hello World” post, I am sure you must be in position to write some basic apps for your Windows Phone 7. Now we already spend some time to explore basics of Phone and other Development Environment. Now from this article onwards let’s try to look further.

3D in Silverlight is nothing new to us now since it has been made available to us by Microsoft from Silverlight Version 3. Since most of the features of version 3 are well supported on phone, 3D is one of them. Open a new Windows Phone Project and Open a Blend Instance to design your app. My 3D app look like this :

Blend3D_thumb19.png?imgmax=800

Posted via email from .NET Info

To XAML, with love (an experiment with XAML Serialization in Silverlight)

|
’m a big fan of XAML.  It provides a nice, declarative, toolable way of defining UI, encourages separation of UI logic and application logic, and is flexible enough to allow an impressive amount of expressiveness.  In addition to being a way to describe a user interface, XAML can be used as a serialization format for arbitrary CLR objects.  A little over a month ago, as I was building out a prototype of an idea I had for a blog post for another time, I found myself looking for a way to quickly and easily serialize some data out into Isolated Storage.  I looked at a few options, such as the XML and JSON serializers in the Silverlight SDK.  Both of these work well for serialization of data, but as I was looking at them, I noticed something that failed to meet my requirements for the task at hand: these libraries are both quite large and would need to be packaged into my XAPs.  System.Xml.Serialization.dll is 314 kb, and System.Runtime.Serialization.Json.dll is 138 kb (uncompressed).  Under many circumstances in large applications, taking such dependencies might be fine, but I was looking for something small that would be acceptable to package into a quick-to-load bootstrapping application.

As a result, I thought I’d spend some time looking for another option.  It occurred to me that in WPF, I might’ve used the XamlWriter for precisely this purpose: to serialize my objects out into text.  As I thought about my options for serialization, taking assembly size into account, I found myself wondering if XAML was a good choice.  After all, Silverlight has a reader (XamlReader) built into the runtime, so I wouldn’t have to build one myself.  Perhaps that would save me the size I was looking for.  Furthermore, in Silverlight 4, the XAML parser got a major overhaul that helped ensure more consistent support of the XAML language, so I felt confident that I could produce a flexible XAML serializer.

With that in mind, I started writing.  At first, I was just hoping to build out some basic serialization into XAML – enough to suit my needs for what I was working on.  But unfortunately, once I start trying to solve a problem, I can’t leave it half-complete!  Just like that, I was hooked on the challenge of seeing how complete of a XAML serializer I could build (which helps explain my blogging absence for the last month  ).

Honestly, I expected to find a large number of issues – limitations of Silverlight that would keep me from collecting enough information to serialize to XAML properly.  The reality, however, was that I could actually get really close to full fidelity.

In the process, I learned a lot about XAML, Silverlight, and myself (a journey of self-discovery, so to speak  ).  In this post, I’ll share my results (happily included for your consumption and experimentation in my latest build of SLaB) as well as some of what I learned.  As usual, I make no promises around support or correctness in all cases.  This is sample code for your edification.  That said, if you do find an issue, please let me know, and I’ll see if I can figure out what’s going on!

POCO, oh, POCO, wherefore art thou?

I started out just trying to serialize POCOs (Plain ol’ CLR Objects).  On the surface, this is pretty straightforward – walk the object graph being serialized, writing objects and property values out using the XmlWriter.  Simple, right?  Well, there’s actually a lot going on here:

Walk the object graph using reflection
Decide whether properties are serializable (i.e. is the property read-only?  If so, is it a collection type?)
Retrieve TypeConverters from both properties and property types (based on the TypeConverterAttribute)
Determine whether to set properties as attributes (<Foo Bar=”Baz” />) or elements (<Foo><Foo.Bar><Baz /></Foo.Bar></Foo>)
Retrieve and honor ContentPropertyAttributes (So that if “Bar” is the ContentProperty of Foo, the example above is serialized as <Foo><Baz /></Foo>)
Determine whether properties should/should not be serialized based on the “ShouldSerializeXXXXX” method and the DefaultValueAttribute
Discover attached properties and repeat all of the above
Manage xml namespace definitions (e.g. xmlns:foo=”clr-namespace:MyAssembly.Foo;assembly=MyAssembly”) and scope
Discover/respect XmlnsDefintion and XmlnsPrefix attributes
Understand serialization of built-in types (e.g. Uri, string, double, int, bool, enums etc.)
Serialize null values (using “{x:Null}”)
Serialize collections
Serialize dictionaries (and make use of “x:Key”)
Properly escape strings (e.g. “{Hello, world!}” needs to get serialized as “{}{Hello World!}”)
Properly handle string whitespace (turning on xml:space=”preserve” at the appropriate times)
Avoid cycles in the object graph (I simply ignore the property if it would cause a cycle – sorry, I’m not a miracle worker!)
Be performant!
Nothing to it, right?  Phew, I’m tired just writing all those down!  Who knew there was so much to that XAML stuff? (answer: Rob Relyea)

Read more: davidpoll.com

Posted via email from .NET Info

Skype SDK Now Available for Windows

|
Developers interested in integrating Skype into their applications can now request access to Skype’s new SDK, called SkypeKit. Available in beta format as of June 14th, the Windows version of the developer’s kit works on Windows x86 operating systems.

Access to the kit is on an invite-only basis at the moment, and interested developers have to go to Skype’s website and fill out an online form detailing their user and organization info.

SkypeKit will allow the integration of voice and video calling and/or IM features into third-party desktop applications or compatible Internet-connected hardware devices. It also offers Skype’s super wideband audio, based on the SILK codec. Developers who use SkypeKit will be able to describe their apps as “plugged into Skype” in their marketing materials, notes a company blog post about the announcement.

Read more: on10
Read more: Skype SDK

Posted via email from .NET Info

Debugging Unit Tests for the iPhone/iPad

|
I have been working my way through a new iPhone app. I have been doing this TDD. One problem that I ran into was one of my tests failed, yet I could not figure out how to get it working easily so I wanted to debug my Unit Tests. This should be straight forward, yet it took me a while to figure out using the metaphors and tools of XCode (built in OCTest). I know that many people will say I should use GHUnit or GTM (Google Toolbox for Mac). I have tried both of these and I really don't like them because they don't feel as integrated into XCode (not that any of these tools do but that is another story). I spent a good bit of time searching around for how to do this for iPhone/iPad apps. The following articles are the best I found (although didn't answer the questions completely):

Apple's Documentation on Unit Testing - This defines the difference between Application and Logic tests.
Chris Hanson's Articles on Unit Testing - A good overview of unit testing on the Mac with XCode
A good description of how to do this on the Apple Mailing List
Another good description at Grokking Cocoa
After reading through these articles and many others I finally came up with the solution. I am using 3.2.3. Most of these articles are talking about earlier versions of XCode. Most of the solutions work (especially the last one). My biggest problem that I wanted to solve is make sure that when I switched SDK (iPhone 4 to iPad 3.2), the custom executable (more on this in a minute), otest, that I used was for the right SDK. Unfortunately, each SDK (Mac OS X 10.x, iPhone and iPad) have their own version of otest. So if I wanted to debug a universal iPad/iPhone application, I needed to point to the right otest.

When you create a UnitTest bundle in XCode, it runs a script to run the Unit Tests when you build that target. If you look at this script (/Developer/Tools/RunUnitTests), you will notice that it figures out what platform you are building for and then calls the RunPlatformUnitTests script. If you go to Terminal and do find /Developer -name RunPlatformUnitTests, you will see that there is one for each platform. Each one of these set specific environment variables and run the correct otest with the bundle passed into the script. Armed with this information and the information I got from the articles I could setup my environment to debug unit tests now.

How to Setup XCode

The first thing I did was add a custom executable to my project (that already had a UnitTest bundle target). I named it otest and pointed it to the otest for the iPhone 4 SDK (you could pick the one for iPad if you want). If you do a find for otest in the Developer directory (find /Developer -name otest) you will see that for each SDK, it is located in the Developer/user/bin/ folder. This was the important part of the puzzle. When you open the general table of your Custom Executable information windows, you will see a drop down for Path Type. Instead of Absolute Path you set this to Relative to Current SDK. This will then allow you to run the corrent otest depending on what SDK you pick.

Read more: LosTechies.Com

Posted via email from .NET Info

Tessnet2

|
Tesseract is a C++ open source OCR engine. Tessnet2 is .NET assembly that expose very simple methods to do OCR. Tessnet2 is multi threaded. It uses the engine the same way Tesseract.exe does. Tessdll uses another method (no thresholding).

Read more: Best Open Source
Read more: Tessnet2

Posted via email from .NET Info

Transferring large data when using Web Services

|
I've been working with complex reporting application and big part of the application relies on Web Services.

The client requests some operations by calling the Web Methods. The Web Service basically does everything on the sever where it is deployed and returns data to the client as byte[] array.

When we have some more complex methods, the maximum message size quota (which is 65536 by default) is exceeded.

When trying to get the byte[] back from the Web Service

byte[] rep = serv.getReport(json);

the error that is thrown is:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

As it says, the MaxReceivedMessageSize property value should be increased.

In Web.config under <system.serviceModel>, once you add web service reference, the bindings and client are generated.

It should look something like this:

<system.serviceModel>
<bindings>
 <basicHttpBinding>
   <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
     allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
   <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
   <security mode="None">
    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
    <message clientCredentialType="UserName" algorithmSuite="Default"/>
   </security>
  </binding>
 </basicHttpBinding>
</bindings>
<client>
 <endpoint address="http://hajan/mywebservapp/MyService.asmx" binding="basicHttpBinding" bindingConfiguration="Service1Soap" contract="HSServ.Service1Soap" name="Service1Soap"/>
</client>
</system.serviceModel>
So, pay attention on the <binding name="Service1Soap ...> element:

Whole line:


<binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">

Read more: Hajan's Blog

Posted via email from .NET Info

Find the Most Time Consuming Code in your SQL Server Database

|
This post will demonstrate how to find T-SQL code (SQL Server 2005/2008) that takes the most time to execute. Note that a time consuming code may not necessarily be inefficient; it also depends on the volume of data being processed.

--Top 10 codes that takes maximum time
SELECT TOP 10 source_code

, stats.total_elapsed_time/1000000 as seconds
, last_execution_time from sys.dm_exec_query_stats as stats
cross apply
(SELECT text as source_code FROM sys.dm_exec_sql_text(sql_handle)  ) AS query_text
ORDER BY total_elapsed_time DESC

--Top 10 codes that takes maximum physical_reads
SELECT TOP 10 source_code
, stats.total_elapsed_time/1000000 as seconds
, last_execution_time from sys.dm_exec_query_stats as stats
cross apply
(SELECT text as source_code FROM sys.dm_exec_sql_text(sql_handle)  ) AS query_text
ORDER BY total_physical_reads DESC

Read more: SQL Server curry

Posted via email from .NET Info

Script to load sos within Windbg based on .NET Framework version

|
I often debug  .NET Framework v 2.0 / v 4.0 code within windbg. In v 2.0 the main clr dll was called “mscorwks.dll” and in v 4.0 it is called “clr.dll”.  As many of you are aware , to load sos in v 2.0 we would have to enter “.loadby sos mscorwks” and in v 4.0 it would be “.loadby sos clr” . This was a pain for me. Came up with a script to automate loading sos based on clr version

!for_each_module .if(($sicmp( "@#ModuleName" , "mscorwks") = 0) ) {.loadby sos mscorwks} .elsif ($sicmp( "@#ModuleName" , "clr") = 0) {.loadby sos clr}

Read more: Naveen's Blog

Posted via email from .NET Info

Class Designer PowerToys for Visual Studio 2010 is Released

|
lass Designer PowerToys for Visual Studio 2010 is released today! It provides a bunch of enhancements to Visual Studio 2010 Class Designer. Click here to download it now.
It has many cool features like pan/zoom window, floating properties window, fast navigation, etc. You could find the detailed feature list in its help document which is available on the desktop after the Class Designer PowerToys is installed.

Besides the binary, the source code is also available. You could extend the PowerToys easily. If you are using Visual Studio 2005 or 2008, please use the below links to get the previous releases.

Read more: Visual Studio Data
Read more: CodePlex
Read more: Class Designer PowerToys for Visual Studio 2008
Read more: Class Designer PowerToys for Visual Studio 2005

Posted via email from .NET Info

Создание и настройка WCF сервиса в Silverlight 4 приложении

| Monday, July 26, 2010
В этой статье мы научимся:
Создавать WCF сервис и бизнес объекты для обработки данных
Создавать форму на Silverlight 4 для отправки данных.

Изучать мы будем на примере: «Рисование и отправка поздравительных открыток другу»

Подготовка

Для работы с Silverlight 4 в Visual Studio 2010 нужно скачать и установить Silverlight 4 Tools. Expression Blend 4 сразу умеет работать с Silverlight 4, а также в нем есть всякие интересные примеры. После установки Silverlight 4 Tools в VS2010 появится возможность открывать проекты SL4 и станет возможно создание и редактирование приложений SL4 в дизайнере.

Когда создается приложение, которое работает с данными, важно начать с создания модели данных, с которыми приложение собирается работать. Мы будем использовать InkPresenter в качестве панели для рисования открыток.

Создание проекта

Мы создадим бизнес объект, который будет использоваться и Silverlight частью нашего приложения и в ASP.NET. В завершении мы создадим бизнес объект в ASP.NET части, который определит контракт данных и его предоставим WCF сервису.

Открываем студию и создаем проект Silverlight Application.


Read more: Habrahabr.ru

Posted via email from .NET Info

Google JavaScript Style Guide

|
JavaScript is the main client-side scripting language used by many of Google's open-source projects. This style guide is a list of dos and don'ts for JavaScript programs.

Read more: Google

Posted via email from .NET Info

Fun with dot

|
The symbol dot (.) plays a major role when you write queries. It is mainly used to speicify the columns for the respective tables when a join is used as you see in the following example

select
t1.col1,t1.col2,t2.col3,t2.col4
from
table1 as t1 inner join table1 as t2 on t1.col1=t2.col1

But sometimes the usage of dot may surprise you. Let us consider the following example

create table #test(i int)
insert into #test(i) select 10
select * from #test

As you see the result is 10. Now see what happens when you use the following queries

select * from .#test
select * from ..#test
select * from ...#test

The result is 10 for all the queries. You may think to get an error when you see the queries

However what happens is
when a single dot is used, by default the current user is considered so it becomes username.tablename
when two dots are used, by default the current database and user are considered so it becomes dbname.username.tablename
when three dots are used, by default the current server, database and user are considered so it becomes servername.dbname.username.tablename

You will get an error if you use more than three dots

Read more: Beyond Relational

Posted via email from .NET Info

C# Code Converter

|
DeveloperFusion offers a free .NET code converter.  Simply paste your C# or VB.NET code into this web-based tool, then select your target language: C#, VB.NET, Python or Ruby.  Supports syntax up to .NET 3.5.

Read more: developerFusion

Posted via email from .NET Info

Glass UI

|
A Windows Forms Control Library built specifically for Aero Glass. This will consist of existing controls, modified to render on glass, as well as some completely custom controls. All controls will also render in non Aero projects, but the main focus will be on glass.

Read more: Codeplex

Posted via email from .NET Info

Converting an Access DB to XML using C#

|
I recently needed to import an Access database into a C# program for a sample that I will be blogging about soon. My objective was to convert the data into a more convenient form for use with my “real” application. Nothing here will be very cutting edge! A quick and dirty way to get the job done seemed to be to read the data into a DataSet and export it to XML. Access MDB files can be read using the Jet OLDB provider with OleDbConnection. Once the connection is established, the GetOleDbSchemaTable method can be used to get the table names. Then each table can be read using a select. Writing the data out to XML is easy using the built-in DataSet.WriteToXml() method. I also write out the schema file so that the columns will have the correct types when I read the data back in.

One last hitch: in .Net 4/VS2010 the OLEDB component works only with a 32-bit build. So change the Platform target in the Project properties as follows:

Here's the code. I’ve made even less of an effort than usual to make the code “production quality”, but note that a couple of the classes I use are IDisposable so I’m taking care to wrap them in a “using” block.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;

// None of this is foolproof...caveat emptor.
namespace AccessToDataSet {
 class Program {
   static void Main(string[] args) {
     if (args.Length == 0 || !args[0].EndsWith(".mdb", StringComparison.InvariantCultureIgnoreCase)) {
       Console.WriteLine("Please specify the path to an MDB file.");
       return;
     }

     DataSet dataSet = new DataSet();
     using (var conn = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=" + args[0])) {
       conn.Open();
       // Retrieve the schema
       DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
       // Fill the DataTables.
       foreach (DataRow dataTableRow in schemaTable.Rows) {
         string tableName = dataTableRow["Table_Name"].ToString();
         // I seem to get an extra table starting with ~. I can't seem to screen it out based on information in schemaTable,
         // hence this hacky check.
         if (!tableName.StartsWith("~", StringComparison.InvariantCultureIgnoreCase)) {
           FillTable(dataSet, conn, tableName);
         }
       }
     }

     string name = args[0].ToLowerInvariant();
     dataSet.WriteXmlSchema(name.Replace(".mdb", ".schema.xml"));
     dataSet.WriteXml(name.Replace(".mdb", ".xml"));


Read more: Nathan Brixius

Posted via email from .NET Info

Microsoft Expression Studio 4 Ultimate Trial

|
Expression Studio opens up a new world of creative possibility. Its professional design tools give you the freedom to make your vision real—whether you’re designing for standards-based websites, rich desktop experiences, or Silverlight. Includes Expression Web + SuperPreview, Expression Blend, SketchFlow, Expression Encoder Pro and Expression Design.

For more information about what else is new in this release, see Expression Studio 4 Ultimate Overview.

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

Posted via email from .NET Info