Microsoft Launches Translation Service

Internet September 10th, 2007

Microsoft launched a service for automatic translation called Windows Live Translator. The site lets you translate a text limited to 500 words or a web page from English to German, Dutch, French, Spanish, Portuguese, Italian, Korean, Chinese, Japanese, Russian.

Microsoft uses Systran to produce most of the translations, but also offers an option to translate computer-related texts using a machine translation system developed in-house. Microsoft’s translation technology has been used to translate technical materials, including MSDN Library.

Tags: ,

Building .NET 3.0 projects from Team Foundation Build 2005 not supported

Software Development, Team System September 8th, 2007

Building .NET 3.0/3.5 projects from Team Foundation Build 2005 not supported. Team Foundation Build 2005 will always invoke the 2.0 Framework’s MSBuild.exe, which does not support building solutions that target the 3.5 Framework.  (The 3.0 Framework shipped with Vista, while the 3.5 Framework is shipping with VS 2008.)

The 3.5 Framework includes new MSBuild bits which allow multi-targeting – i.e. MSBuild 3.5 can target the 2.0 Framework.

We can convert our solution to VS2008 beta 2 and target the solution to .NET framework 2.0. It’s not enough. When we’ll try to build this solution with Team Foundation Build 2005, we’ll get an error MSB5014 – File format version is not recognized.

The MSBuild blog has great post about MSBuild, Orcas, and Multi-targeting. Find it here.

Tags: , ,

SqlBuildTask timeout

Software Development, Team System September 8th, 2007

I built a big DB Dude project from MSBuild command line and got a timeout error.

MSBUILD : Build error TSD158: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

The default timeout for query execution is 60 seconds and stored in the registry. We can extend the query timeout by changing these values. The registry entries are:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\DBPro\Database\QueryTimeoutSeconds

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\DBPro\Database\LongRunningQueryTimeoutSeconds

Tags: , ,

Lambda expressions introduction

Software Development September 7th, 2007

NET 2.0 introduced Anonymous Methods. The idea behind anonymous methods it to write methods inline to the code. They are mainly used for small methods that don’t require any need for reuse. For example, we have this code:

   1: bool isGreaterThan5(int n)
   2: {
   3:     return n > 5;
   4: }
   5:  
   6: ...
   7:  
   8: int GetGreatersThanFives(List<int> numbers)
   9: {
  10:     return numbers.Find(isGreaterThan5);
  11: }

We can code it with anonymous method:

   1: int GetGreaterThanFives(List<int> numbers)
   2: {
   3:   return numbers.Find(
   4:         delegate(int n) { return n > 5; }
   5:     );
   6: }

c# 3.0 represent cool thing: Lambda expressions.
Lambda Expressions make things easier by allowing you to avoid the anonymous method and that annoying statement block.

Instead

   1: delegate(int n){ return n > 5; }

We can write:

   1: n =>  n > 5

The form of Lambda expressions is:

argument-list => expression

Parameters to Lambda Expressions

The parameters of a lambda expression can be explicitly or implicitly typed. In an explicitly typed parameter list, the type of each expression is explicitly specified. In an implicitly typed parameter list, the types are inferred from the context in which the lambda expression occurs:

   1: (int x) => x + 100         // explicitly typed parameter
   2:  
   3: (x,y) => return x * y;    // implicitly typed parameter

Lambda Expressions with Multiple Parameters

   1: (x, y) =>  return x * y

Lambda Expressions without Parameters

   1: () => Console.WriteLine("Hello world!")      // No parameters

I think that’s enough intro to Lambda Expressions.
I will follow up with a part 2 to show more about this cool fteature: Expression Trees, how LINQ uses it to pass code as parameters and more.

Tags: ,

SqlMetal for Linq

Software Development September 7th, 2007

SqlMetal builds a data access layer in seconds. The output is not just a first generation data access; SqlMetal’s output includes all defined relationships (based foreign keys) between your tables. SqlMetal will produce a class for each table and, optionally, classes for all views, stored procedures and user-defined functions.

SqlMetal can generate strongly typed interfaces for stored procedures and user-defined functions. From the developer point of view, it is now a complete breeze to call either a stored proc and/or a user-defined function.

SqlMetal can generate a DataContext for your entire database with a single command.

This is very useful if you have a large number of tables in your system, as dragging and dropping them onto the designer would have got boring very quickly. You can find SqlMetal at [C:]\Program Files\Microsoft SDKs\Windows\v6.0A\bin\.

Lets create Northwind datacontext:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>sqlmetal /server:.\sqlexpress
/database:northwind  /code:”c:\temp\northwind.cs”

We can then include the class within our project and use it as if the designer had created it. We can also get SqlMetal to include all of our views, functions and stored procedures. (use /sprocs /views /functions to extract these objects).

SQLMetal can also output the dbml (/dbml:file.dbml) or mapping (/map:file.xml) file for the database.

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>sqlmetal /server:.\sqlexpress
/database:northwind /dbml:”c:\temp\northwind.dbml”

SqlMetal has also generated an external XML Mapping File that maps the classes generated to the database tables, which is much more complete than what I had done my self…

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>sqlmetal /server:.\sqlexpress
/database:northwind /map:”c:\temp\northwind.map”

Conclusion:

The SqlMetal tool is useful to generate C# or VB.NET objects mapped on SQL Server database. It provides classes with members and properties mapped on table and view columns. It reflects the relationships between tables. It provides also a class derived from base class DataContext which maps, on request, functions and stored procedures, making difference between table functions and scalar functions and between stored procedures which returns a rowset and those who perform only operations such as insert, update and delete.

From my point of view: great and useful tool.

 

Technorati Tags:

 

del.icio.us Tags:

Tags: , ,

Windows Live Writer Beta 3 Released

Internet, Software Development September 6th, 2007

Highlights of the Windows Live Writer Beta 3 Release:

  • Insert videos using our new ‘Insert Video’ dialog
  • Upload images to Picasaweb when publishing to your Blogger blog
  • Publish XHTML-style markup
  • Use Writer in 28 additional languages
  • Print your posts
  • Justify-align post text
  • Better image handling (fewer blurry images)
  • Resolved installation issues from last release
  • Many other bug fixes and enhancements

Download here.

Tags: , ,

Deploy .NET Apps with ClickOnce

Software Development September 5th, 2007

I wrote a post about it. You can read it here.

Technorati Tags:

del.icio.us Tags:

Tags: ,

Object Initializers in C# 3.0

Software Development September 5th, 2007

C# 3.0 includes a new language feature called object initializers.

Object initializers enable you to initialize the state of an object with a single expression that does not require use of parameterized constructors.

Basically, this feature allows you to initialize an object by both creating the object instance (i.e. a new expression) as well as assign values to one or more properties in a single sentence, or to initialize a collection with a set of values to add to it in a single expression.

    class Program    {        static void Main(string[] args)        {            Customer cus1 = new Customer() { Name = "Maor", City = "Herzliya" };            Customer cus2 = new Customer() { Name = "Guy", City = "Ramat Hasharon" };

            List<Customer> customers = new List<Customer>() { cus1, cus2 };

        }    }

    class Customer    {        public string Name { get; set; }        public string City { get; set; }

    }

The first & the second lines initialize a Customer object with the default constructor (though you could call a constructor with parameters here), and assigns explicit values to the Name and City properties.

The third line initializes a collection of type List<Customer> with the objects cus1 and cus2.

del.icio.us Tags:

Technorati Tags:

Tags: ,