Tuesday, April 22, 2008

While waiting for Enterprise Library 4, you might want to use Entlib 3.1 with Visual Studio 2008.  All the blocks will work but the VS integration will not.  Does that mean you're stuck editing the config file by hand?  Not at all, all you need is add a few registry entries by downloading a .REG file from CodePlex.

http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=entlibcontrib&ReleaseId=11669

The steps are:

  1. Install EntLib 3.1
  2. Run the .REG file
  3. From the VS command prompt, run devenv /setup

Voilà!

Tuesday, April 22, 2008 8:42:29 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Wednesday, April 16, 2008

With his own VS 2008 hockey puck and Hockey Canada jersey, ScottGu is now an official honorary Canadian!

Wednesday, April 16, 2008 3:43:34 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Monday, April 14, 2008

I finally made it to Seattle.  Why do I say finally?  Well, we were flying American Airlines, you know, the airline that grounded all its MD-80 last week and guess what?  6 MVPs from Montreal were flying on MD-80s Sunday morning flights!  So it's not until Saturday that we had a confirmation from AA that our flights were not cancelled.

Upon arrival, we were looking for a way to get to our downtown hotels when I noticed a couple of stretched limos.  I asked our much the ride was and it would have been the same price as riding a shuttle so guess what?  The Montreal MVPs arrived to their hotels in grand style:


Laurent Duveau, Dominic Sevigny and Etienne Tremblay


Me, Eric Moreau and Mario Cardinal

Monday, April 14, 2008 9:02:32 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Friday, April 11, 2008

I was trying to return a WCF custom FaultException and just couldn’t figure out how to read the custom info I was sending from the client when I found this blog entry from Jean-Paul Smit:
http://bloggingabout.net/blogs/jpsmit/archive/2007/03/21/wcf-fault-contracts.aspx

My comprehension of the whole process was OK, I was just missing one key element and the light came thru when I read this line:

  • in ex.Detail you can find your custom fault contract

Funny how a single line of text in a short blog entry can help you a lot sometimes  :-)

Friday, April 11, 2008 2:09:43 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Thursday, April 10, 2008

Some of the experts at the Launch 2008 Montreal Technical Readiness 2008: Bertrand, Laurent Duveau, Etienne Tremblay and Mario Cardinal.

Very very crowded!

BTW, I forgot to credit Jean-Luc David for the picture in my previous post.  Thanks JL!  Check his pictures here: http://www.flickr.com/photos/jldavid

 

Thursday, April 10, 2008 7:39:48 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Wednesday, April 09, 2008

Some of the experts at the Launch 2008 Montreal Technical Readiness 2008 ATE Booth:

Wednesday, April 09, 2008 7:19:30 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

Interesting numbers on Microsoft Certified Professionals Worldwide:
http://www.microsoft.com/learning/mcp/certified.mspx

 

Wednesday, April 09, 2008 7:13:52 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Sunday, April 06, 2008

In my previous post (LINQ to SQL in multi layered + service apps), I mentioned how LINQ to SQL can be used in WCF apps but how to you deal with concurrency checking?  One way is to use a Timestamp column in your tables.  This is a binary type so how will WCF deal with that?

LINQ to SQL maps the SQL Timestamp type to the System.Data.Linq.Binary type.  If you add a DataMember attribute to a System.Data.Linq.Binary field, it will work.  WCF will not choke on that.  So what does the client sees?  Something like this: Service1.Binary.

This whole thing may leads to a few problems:

  1. Binary stuff is not very interoperable
  2. Service1.Binary != System.Data.Linq.Binary

One solution is to convert the info from Binary to String.  Andrew Siemer posted a couple of extension methods that allow you to do just that.  Check it out:
http://geekswithblogs.net/AndrewSiemer/archive/2008/02/11/converting-a-system.data.linq.binary-or-timestamp-to-a-string-and-back.aspx

Simple and easy and you can convert the data right into your LINQ to SQL queries.

 

Sunday, April 06, 2008 8:00:48 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

In my previous post, one reader commented that the proposed LINQ query would be utterly slow so I did a quick unscientific showdown.

In the left corner: the query returning complex objects from anonymous types:
var q = from o in ctx.Orders
        where o.CustomerID == id
        select new { Detail = o.Order_Details, CustomerID = o.CustomerID, OrderDate = o.OrderDate, OrderID = o.OrderID, ShippedDate = o.ShippedDate, ShipCity = o.ShipCity };

In the right corner: the query returning complex objects from POCOs:
var q = from o in ctx.Orders
where o.CustomerID == id
select new TransportObjects.Northwind.Order {
Detail = o.Order_Details.Select(item => new  TransportObjects.Northwind.OrderDetail {
ProductID = item.ProductID 
}).ToArray(),
CustomerID = o.CustomerID, OrderDate = o.OrderDate, OrderID = o.OrderID, ShippedDate = o.ShippedDate, ShipCity = o.ShipCity};

The weapons: 50,000 orders each having 10 order details rows meaning 500,000 objects.

The result: it's a tie!

Yep, both queries returned the results in about 2 seconds using SQL Server Express 2005 locally (no layers, no WCF etc)

 

Sunday, April 06, 2008 7:41:59 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Friday, April 04, 2008
Friday, April 04, 2008 8:46:36 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Wednesday, April 02, 2008

In my previous post about using LINQ to SQL in multi layered apps, I mentioned that this query was not optimal because I would need to build the POCOs from the objects returned by LINQ.  This would mean that objects would be created twice. 

var q = from o in ctx.Orders
        where o.CustomerID == id
        select new { Detail = o.Order_Details, CustomerID = o.CustomerID, OrderDate = o.OrderDate, OrderID = o.OrderID, ShippedDate = o.ShippedDate, ShipCity = o.ShipCity };

Not ideal so I asked if anyone had an idea on how to do that.  Stefan Sedich suggested this query:

var q = from o in ctx.Orders
where o.CustomerID == id
select new TransportObjects.Northwind.Order {

Detail = o.Order_Details.Select(item => new  TransportObjects.Northwind.OrderDetail {
ProductID = item.ProductID 
}).ToArray(),

CustomerID = o.CustomerID,
OrderDate = o.OrderDate,
OrderID = o.OrderID,
ShippedDate = o.ShippedDate,
ShipCity = o.ShipCity};

Cool!  The query returns the Order complex object with the Detail property filled from orders Details.

Thanks a lot Stefan!

 

Wednesday, April 02, 2008 7:04:54 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Tuesday, April 01, 2008

Enterprise Library 4.0 March 2008 CTP was released yesterday.

http://www.codeplex.com/entlib

Tuesday, April 01, 2008 8:03:08 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

My good friend Mario Cardinal just got one article published on MSDN.  It's called The Hidden Roles of Software Architects.  Check it out:
http://msdn2.microsoft.com/en-us/library/cc431351.aspx

Tuesday, April 01, 2008 7:52:47 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

Team Suite Vnext will be FREE (but ad supported)

At Mix08 in Las Vegas, I had the chance (!) to be invited to a special meeting.  The invite was for only 12 people and it was to demonstrate a revolutionary new Visual Studio feature.  We gathered with Scott Guthrie in a private room at the Aquaknox restaurant at the Venetian hotel where we were treated with exquisite seafood that would have a bad taste later on.

So what is that revolutionary new Visual Studio feature?  Well, Microsoft plans to offer the next Visual Studio Version for free.  Yeah, Visual Studio Express is already free you might say but I’m talking about the Team Suite here!  Yep, Microsoft plans to offer the $10K product for free!!!  So watch the catch?  Isn’t that some good news?  Well, Microsoft has some large teams dedicated to the development tools and they need to generate revenues to pay for those salaries so the Visual Studio VNext will be free but add supported.  You might say that’s it’s a good deal because you get a $10K product for free by watching a few non obstructive ads well here the catch: the ads are obstructive.  How obstructive?  Check this out.
First of all, the advert system code name is called Barracuda.  It is already included in the August CTP of Visual Studio Team Suite code name Rosario.  You may have downloaded that version and found nothing special; this is because it is not activated by default.  To activate it, Microsoft has created something clever: you need to input a special set of buttons from an Xbox 360 game controller!

So you need to connect an Xbox 360 controller to an USB port (the wireless one will also work) on the machine running Rosario and you need to input the button sequence in this precise order:
At the same time: press the Left trigger + Right trigger + Left thumbstick UP + Right thumbstick DOWN
While the above are pressed, press the D-pad in this order: Up, Left, Up, Down, Up, Right
If you entered the correct sequence, the controller will vibrate and this dialog will pop-up inviting you to restart Visual Studio.

After restarting Visual Studio, create a class library project and take a look at the code.  Yep that’s an ad placed directly on top of your code and no way to turn it off!

Now shut down Visual Studio, unplug your network cable so you don’t have any Internet access and restart Visual Studio.  You’ll be prompted by this dialog:

Yes, an Internet connection will be required to use that free ad supported Visual Studio.  If you dismiss this dialog, Visual Studio just closes.  That’s it!  Impossible to use it on the train or at a client without being connected to their network.  How convenient!

Now the shocking part (yes there are more shocking news!): when the application is compiled and deployed, the add system doesn’t go away because it’s built in the .NET Framework 4.0. When your users will start your app, they will be presented with an ad!

Microsoft has not completed the Web start-up ad yet but the plan is to whenever a new session starts, the start-up ad will be presented in a DHTML window over your actual application in the browser.  Shocking?  Wait, there’s more!
The ad system is connected with ADO.NET so ads are inserted right into the data you’re displaying.  The plan is to have one ad being displayed at all time in grids. 

Oh BTW, your users will also have to be connected to the Internet or your app will simply not run!

I don’t know about you but that whole ad supported Visual Studio thing smells fishy.  I don’t like it at all and I’d rather pay for Visual Studio then get it for free and annoy my users.  Before posting this info, I contacted Scott Guthrie for voicing my concerns.  This is what he had to say:  April Fools!!!!

 

Tuesday, April 01, 2008 5:53:04 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 
Monday, March 31, 2008

The P&P group recently published a set of WCF security related guidance.  You'll find on this CodePlex site a series of articles and videos.

http://www.codeplex.com/WCFSecurity

Monday, March 31, 2008 9:00:11 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

In a previous post, I was explaining how surprised I was when I discovered that you lose LINQ to SQL change tracking features when working in a multi layered application or when you expose your business logic thru a service layer.  Thanks to everyone (especially Barry Gervin, Rocky Lhotka, Julie Lerman and Rick Strahl) who pointed me to articles, blog posts and code samples, I was able to make sense of all of this.

Let’s take a look back at my rant and see how I can address each of these points.  BTW, this is by no means the only way to achieve the goal of using LINQ to SQL in a multi layered application.  It’s just simple and easy.  Feel free to comment and share your findings and thoughts.

1-The presentation layer must reference the DAL directly because this is where the data mapping classes are located.  Yuck!
Referencing the DAL objects from the presentation layer is bad because you’re creating a strong bond between these layers that are supposed to be decoupled.  The rule states that the presentation layer must not be aware of the data access layer.  What you really need to do is create a transport object layer that will be referenced by the BAL and the DAL.  These objects are just plain POCOs (Plain Old CLR Objects) that will cross all the layers.
   
    public class Customer
    {
        public string CustomerID { get; set; }

        public string CompanyName { get; set; }

        public string ContactName { get; set; }

        public string City { get; set; }

    }


In your LINQ query, just map the data directly back to your POCO.  In this example, the data is mapped back to the Customer POCO.

public static List<TransportObjects.Northwind.Customer> SelectAllCustomers()
{
using (LINQ.NorthwindDataClassesDataContext ctx = new LINQ.NorthwindDataClassesDataContext())
      {
       var q = from c in ctx.Customers
            select new TransportObjects.Northwind.Customer {CustomerID = c.CustomerID, ContactName = c.ContactName, City = c.City, CompanyName = c.CompanyName };

       return q.ToList< TransportObjects.Northwind.Customer>();
       }
 }

2-By returning POCOs to the presentation layer instead you lose all the change tracking stuff provided by LINQ to SQL.  Yuck!
One of the LINQ to SQL benefits is change tracking.  Beside the actual data that is mapped to the objects, LINQ to SQL keeps a copy of that data so when you call the SubmitChanges method of the DataContext object, LINQ to SQL can figure out the objects that changed and can apply these changes (CRUD) back to the database.  And yes, by having a transport objet, you are losing the change tracking benefit but it’s not the end of the world.

3-Exposing the BAL layer as a set of WCF services you lose the change tracking stuff.  Yuck!
Change tracking IS state and state is bad in service oriented apps because by definition, they are supposed to be stateless.  OK so how I’m supposed to return my POCOs back to the presentation layer using a WCF service layer?  Simple, use the [DataContract] and [DataMember] attributes in your POCOs.  Now they can cross the WCF service layer.

    [DataContract]
    public class Customer
    {
        [DataMember]
        public string CustomerID { get; set; }

        [DataMember]
        public string CompanyName { get; set; }

        [DataMember]
        public string ContactName { get; set; }

        [DataMember]
        public string City { get; set; }

    }

4-And what if I want to data bind my grid?  Using the designer, I need to point to the DataClasses sitting in the DAL.  Yuck!
No need to reference the LINQ classes to generate the correct bindings.  After adding a service reference in your presentation layer, connect the BindingSource object to the WCF proxy classes then when you receive an array of POCOs from the WCF service layer, you only need to bind it to your grid.

5-OK, I'll lose the change tracking stuff.  Now I'll have to reload each record before saving it?  Yuck!
Yep, that’s one way to do it but you can apply business rules while doing that.  You can of course do all of this in store procs.

 

That’s it!  Not bad at all, right?  Sure you lose the change tracking feature but you get the benefit of using LINQ to SQL in your DAL.

Drawbacks?
One drawback is when you have complex POCOs like the Order and OrderDetail ones with the Order object having a property of type OrderDetail.  I haven’t found a way to return the Order object correctly stuffed with the OrderDetail data directly from the LINQ query.  What I do is return an anonymous type then loop to build my POCOs, the drawback being that two object creation phases are needed: one for the anonymous types and one for the POCOs.  I wouldn’t return thousands of records this way!  I would simply use a store proc or plain old ADO.NET to retrieve the data, and then build the POCOs.  If somebody has a clever way to do this, please post a comment!

    [DataContract]
    public class Order
    {
        [DataMember]
        public int OrderID { get; set; }

        [DataMember]
        public string CustomerID { get; set; }

        [DataMember]
        public DateTime? OrderDate { get; set; }

        [DataMember]
        public DateTime? ShippedDate { get; set; }

        [DataMember]
        public string ShipCity { get; set; }

        [DataMember]
        public OrderDetail[] Detail { get; set; }

    }

    [DataContract]
    public class OrderDetail
    {
        [DataMember]
        public int OrderID { get; set; }

        [DataMember]
        public int ProductID { get; set; }

        [DataMember]
        public decimal UnitPrice { get; set; }

        [DataMember]
        public int Quantity { get; set; }

    }

        public static TransportObjects.Northwind.Order[] SelectCustomerOrders(string id)
        {
            using (LINQ.NorthwindDataClassesDataContext ctx = new LINQ.NorthwindDataClassesDataContext())
            {

                List< TransportObjects.Northwind.Order> ordersList = new List<TransportObjects.Northwind.Order>();

                var q = from o in ctx.Orders
                        where o.CustomerID == id
                        select new { Detail = o.Order_Details, CustomerID = o.CustomerID, OrderDate = o.OrderDate, OrderID = o.OrderID, ShippedDate = o.ShippedDate, ShipCity = o.ShipCity };

                foreach (var order in q)
                {
                    TransportObjects.Northwind.Order tempOrder = new TransportObjects.Northwind.Order();
                    tempOrder.CustomerID = order.CustomerID;
                    tempOrder.OrderDate = order.OrderDate;

                    List<TransportObjects.Northwind.OrderDetail> ordersDetailList = new List< TransportObjects.Northwind.OrderDetail>();

                    foreach (var orderDetail in order.Detail)
                    {
                       
                        TransportObjects.Northwind.OrderDetail tempOrderDetail = new TransportObjects.Northwind.OrderDetail();
                        tempOrderDetail.ProductID = orderDetail.ProductID;
                        ordersDetailList.Add(tempOrderDetail);
                    }

                    tempOrder.Detail = ordersDetailList.ToArray<TransportObjects.Northwind.OrderDetail>();
                    ordersList.Add(tempOrder);
                }

               return ordersList.ToArray<TransportObjects.Northwind.Order>();

            }
        }

Hope this helps!

Monday, March 31, 2008 8:45:21 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 

When coding apps that use LINQ to SQL, it is very important to check the SQL code generated to make sure that your queries are optimals.  To do this in a Console app, you simply use this code to output the query to the Console window:

ctx.Log = Console.Out;

That's nice but what if your code is in a class library project?  Wouldn't it be nice to output the query to the Output window?  Kris Vandermotten has created a small utility class to do just that.  Check it out here:
http://www.u2u.info/Blogs/Kris/Lists/Posts/Post.aspx?ID=11

Nice work!

Monday, March 31, 2008 7:47:55 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Sunday, March 30, 2008

Accueil

Eric De Carufel: Volta et le futur de la plateforme .NET

Nous discutons avec Eric De Carufel de la technologie Volta et de son impact sur la plateforme .NET. Volta est une des technologies développées par Microsoft Research dans le cadre du projet Tesla.

Eric De Carufel est conseiller chez CGI à Montreal. Il se spécialise dans le développement d’applications à l’aide de la plate-forme Microsoft .NET. Il possède plus dix années d’expérience en conception d'application d'entreprise dans les domaines du transport, de l’alimentation, de l'assurance et de l’ingénierie. Eric est membre du Groupe d'usagers Visual Studio .NET de Montreal et il est un collaborateur de Universal Thread Magazine. Eric est certifié développeur d’applications Microsoft (Microsoft Certified Application Developper – MCAD).

Télécharger l'émission

Si vous désirez un accès direct au fichier audio en format MP3 ou Windows Media (WMA), nous vous invitons à télécharger le fichier en utilisant un des boutons ci-dessous.

         

Si vous désirez utiliser le feed RSS pour télécharger l'émission, nous vous invitons à vous abonnez en utilisant le bouton ci-dessous.

Si vous désirez utiliser le répertoire iTunes Podcast pour télécharger l'émission, nous vous encourageons à vous abonnez en utilisant le bouton ci-dessous.

Sunday, March 30, 2008 3:32:13 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
Sunday, March 23, 2008

Last year, I bought a Dell Vostro 1700 with an Nvidia GeForce 8600M GT 2560MB graphic card with a respectable rating of 4.5 for Aero and 5.1 for gaming.

Dell_vostro_17001.jpg

Of course, one of the first thing I did was to download the latest drivers from the Nvidia Website.  To my surprise, Setup refused to install the drivers.  After a little digging, I found that these drivers, altought good for all Nvidia graphic cards (desktop + mobile), don't install on laptops.  Looks like Nvidia leaves that to the laptop manufacturers.

Looks like I was behind using ForceWare 156.69...

...so I went looking for upates on Dell's Website and I only found this:

Funny, Dell's latest drivers are dated June 2007 and version 101.43.  Hummm, not good but I decided to give them a try anyway.  Well, after the install, the Nvidia control panel reported that I was using ForceWare 101.43.  Doh!

Worse, the Vista Aero rating went down from 4.5 to 4.4!

Since that was stepping back, I did a little research and found the LaptopVideo2Go Website.  It's run by a bunch of enthousiasts that modify the INF file coming with the Nvidia setup so that the drivers are installable on laptops.  Interesting!

WARNING: This might void your warranty, cripple your laptop forever, bring deadly plagues to the earth, render your dog blind, get your hair on fire, etc.  Don't do this unless you backup your laptop, send flowers to your mother, give to United Way and learn to dance the salsa.  You've been warned!

So I downloaded the latest drivers from the LaptopVideo2Go Website along with the modified INF file and I installed them.  After the installation, the Nvidia control panel reported that I had ForceWare 169.09.  Cool!

Now what about that Vista rating?  Aero went back up to 4.5 and the gaming one went from 5.1 to 5.2.  Yeah!

Sunday, March 23, 2008 9:15:15 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 
Friday, March 21, 2008

While doing a little browsing, I found a product that let you program with PHP inside Visual Studio 2005 & 2008.  They even have a standalone version for those who don't have Visual Studio installed.  The price is dirt cheap: $99.  The only strange thing is that there is absolutely no info at all about the company on their Website.  Strange is you ask me.

www.jcxsoftware.com

VS.Php for Visual Studio 2008

Friday, March 21, 2008 4:08:11 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

Theme design by Jelle Druyts