Saturday, July 26, 2008

Using ASP.NET Application Services


MSDN has a very good walkthrough on exposing and using ASP.NET Application services at this link. Unfortunately, it is marred by several technical mistakes and lack of cautionary notes on connection issues commonly encountered in distributed system.




  1. When creating services mapping files(.svc) for Authentication, Profile and Role application services to the web site, instead of

    <%@ ServiceHost Service="System.Web.ApplicationServices.AuthenticationService" ServiceHosting="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>,


    it should be


    <%@ ServiceHost Service="System.Web.ApplicationServices.AuthenticationService" Factory="System.Web.ApplicationServices.ApplicationServicesHostFactory" %>.


    Without this change, when you point to http://localhost:8080/YourWebAppName/AuthenticationService.svc, you will get a server error, like this one:





  2. In the walkthrough, the application services client is a windows console application. In GetProfileInfo() method, ProfileService proxy is instantiated like this:


    ProfileServiceClient profileSvc = new
    ProfileServiceClient();


    It should be like this:



    BasicHttpBinding binding = new
    BasicHttpBinding();



    string ProfileUri =



    @"http://localhost:8080/AppServicesWalkthrough/ProfileService.svc?wsdl";



    ProfileServiceClient profileSvc = new
    ProfileServiceClient(binding, new
    EndpointAddress(ProfileUri));



    In GetUserRole() method, RoleService proxy is instantiated like this:



    RoleServiceClient roleSvc = new
    RoleServiceClient();


    It should be like this:



    BasicHttpBinding binding = new
    BasicHttpBinding();



    string RoleUri =



    @"http://localhost:8080/AppServicesWalkthrough/RoleService.svc?wsdl";



    RoleServiceClient roleSvc = new
    RoleServiceClient(binding, new
    EndpointAddress(RoleUri));


    Essentially, without specifying binding info and service URI, the proxy will fail and generate the error like this one when you run the client and try to connect to application service:






  3. To test the client, another thing you need to do but the document fails to mention is to disable firewall. If you don't you will bump into this error:


Monday, July 14, 2008

Learning AJAX and JavaScript(part 1):

Why learn JavaScript now?

Rich internet application(RIA) fattens the web UI considerably. HTML sprinkled with JavaScript event module won't cut it any longer. Before Silverlight and Air matures to a level that can seamlessly migrate current web app, JavaScript is the only option available.

Can't we rely on server technology such as ASP.NET/Google Web Toolkit to generate JavaScript for us(also referred as indirect Ajax programming)? Good question, and all these players are trying hard and they are getting there. But there still be the rare and critical situation in your project that you need to rollup your sleeves and do it yourself without help of tools. And I also think there are just too many indirection involved when using these tools. UI rendering requires a lot of trial and error iteration, and if tools add more steps in the middle, you may need to rethink about using them. Also Ajax as a web app pattern, there are still a lot to be explored and to explore we will need JavaScript as a tool to gain finer control of the whole HTTP communication process.

Cookbook approach to pick up JavaScript

  1. How to do drag and drop?
  2. How to create pop-up panel?
  3. How to enable bookmark in Ajax app? (Google map uses "add a link" link to solve this)

Some patterns in JavaScript based fat UI

  1. Browser-side templating(BST

    and this link

  2. HTML Message (HTM) and this link

Comparison of Ajax library

  1. ASP.NET Ajax library comparison

    http://www.daniel-zeiss.de/AJAXComparison/Results.htm

  2. OSS Ajax library comparison

    http://www.sitepoint.com/article/javascript-library

Monday, July 07, 2008

Office Programming: Two Namespaces for navigation Package

There are two namespaces to leverage on when developing office application

  • System.IO.Packaging in WindowsBase assembly and it is part of .NET framework 3.0 and 3.5
  • DocumentFormat.OpenXml.Packaging is in DocumentFormat.OpenXml assembly which is part of OpenXml SDK

Eric White has a very good post on the difference of the two namespaces

The two namespaces serve the same purpose as to provide API to navigate within OpenXml document package, the difference is that DocumentFormat.OpenXml.Packaging provides strongly typed classes ie. WordProcessingDocument, SpreadSheetDocument, PresentationDocument, while System.IO.Packaging doesn't.


Resources for System.IO.Packaging

Resources for DocumentFormat.OpenXml.Packaging

Customize Office 2007 Ribbon using Visual Studio 2008(Part 2)

In part 1 of the series, I posted a question as where are the Office Add-In built by VS 2008 saved, and today I somewhat find out an answer (though it is not complete answer yet) with help of this blog

The AddIn is physically located at C:\YourAddInDir\Bin\Debug, and when Office application starts, it looks into following registry location for custom AddIns developed by user

  • HKCU\Software\Microsoft\Office\<App>\AddIns

To see it, open a PowerShell window, and do the following

  • cd Registry:: HKCU\Software\Microsoft\Office\Word\AddIns
  • dir
  • get-itemproperty WordSearch format-list

Still some questions remain:

  1. How many places the Office app look during its startup?
  2. Where are all the MS built-in customizations located?

Sunday, July 06, 2008

Book Review: The Bug A Novel by Ellen Ullman

How do I know about it: I was looking at Daemon reader comments, and one of the comment recommended this one. And as it happens, local library has a copy.

What I like: As a developer myself, I feel "real" about the story. The novel is about software developer and omnipresent bug fixing in software development process. A psychological drama with considerable twist of technical adventure, if you can appreciate some quite psudo code and C code. The author comes from a developer background as evidenced in the explanation of the bug and famous Game of Life by John Horton Conway. And its depiction of professional developer's daily life is realistic and truthful. It talked about the software development in early eighties, but the relevance still holds. I would give it 3 stars out of 5. People in software business will be able to appreciate it much better.

What I don't like: The book cannot be categorized as techno thriller. As exciting as bug finding and fixing is to brainy kids and developers, it just cannot stir the same excitement as true techno thriller. I am still looking forward to my shipment of Daemon from Amazon. Also a little too much algorithms explanation and coding deciphering in the book for non-software people.

Thursday, July 03, 2008

Customize Office 2007 Ribbon using Visual Studio 2008(Part 1)

This link provides a good walk through on Ribbon customization using Visual Studio 2008.

Displaying a Directory Search Custom Task Pane from the 2007 Office Ribbon

The question is : Where are the new customization saved in ? normal.dotm? But inside it, I don't see a customUI.xml file.

Q&A: How to find all the idMso for Office applications

Q: Office 2007 comes with a new Ribbon user interface, and all the built-in controls on it have id, these ids are special id called idMso. For example, File Save button's idMso ="FileSave", Developer tab's idMso="TabDeveloper". To customize Ribbon UI, many times you need to know idMso for the built-in controls you want to customize. But how to find what all idMso are for Word, Excel, Access and Outlook?

A: According to Customizing the 2007 Office Fluent Ribbon for Developers (Part 3), here is how:

  1. Click the Microsoft Office Button, and then click Application Options.
  2. Click Customize, and then select the item you want information about.
  3. Move the pointer over the item. The dialog box displays the control's idMso value in a ScreenTip, in parentheses.

Wednesday, July 02, 2008

Vista: Search can be tricky

One of the most talked about features of Vista is its search capability. You can search from search bar on start menu, or you can search from Windows Explorer search box. But you can be tricked by search results. I was trying to search a customUI.xsd file that I pretty sure exist on my machine, but search bar on start menu said no.




I was a little taken aback. So I went to Windows Explorer and navigated to the directory where I believe the file exists, and did a search right there using Windows Explorer search box, Voila! This time search finds it, as shown in the picture below:








So the trick is to add the more locations to Vista search indexer. To add more locations, in Windows Explorer, type something random in search box to turn on the Search Tools option and set the index locations from there, as shown in picture below:

Tuesday, July 01, 2008

LINQ to XML: Use it with Office 2007 documents

Last couple of months I have been focusing on learning Language Integrated Query (LINQ). One flavor of LINQ is LINQ to XML, an extremely powerful XML API to query and transform XML data. One problem I had when learning LINQ to XML is that simple XML data like <Customer><Name>John Smith</Name></Customer> can only get you so far. Eric White mentioned in his blog that OpenXML(which is the underlying format for Office 2007) is a good source and provided some very good samples on using LINQ to XML to manipulate Office 2007 documents. With vast amount of data parking in Office documents, LINQ to XML should be a good tool for mining this valuable data source.

Here are some other good LINQ to XML tutorials:


Migration to Visual Studio 2008 and .NET 3.5

Being a procrastinator, I finally take the dive and migrate to Visual Studio 2008 and .NET 3.5 platform today. By migration, I mean installing Visual Studio 2008 and converting all the VS 2005 projects to VS 2008. And uninstall Visual Studio 2005 completely from my hard drive. Part of the reason for the switch is that I have been learning LINQ for last couple of months on the VS08 installed on my laptop, and I feel comfortable enough now to upgrade my workhorse desktop setup to the VS2008. All things seem go well, the project I have been working on migrated well too. Everything compiles, including the website, WinForm application, DAL, BLL and all the goodies. And after a quick run-through, everything seems to work too. Next step: refactoring some of the code to more functional style and LINQish. Keep tuned.

Monday, June 30, 2008

Q&A: How to change file extension in Vista

Q: In Vista, how can I change a file named like FileWithWrongExtension.docx to FileWithWrongExtension.zip?

A: Open an Explorer window, click Organize dropdown on Ribbon bar, then select Folder and Search Options. This will bring up Folder Options window with General/View/Seach tabs. Click View tab, uncheck Hide extensions for known file types in Advanced Settings section. This will enable the Explorer to show file extension. Now you can change the file extension right there in the Explorer.

Saturday, June 28, 2008

How to get ahead

Recently, due to the unexpected changes in life as it always is, I am out of job and find a lot of time on my hand. So I take advantage of it and start to check off the ever-growing To-Read/To-Do list that get accumulated during my hectic working days, lot of them new technologies that I found relevant yet didn't have time to explore. And also I a lot of catch up with all blogs I subscribe to and my own blogs.

Then it hits me that all those bloggers are working professionals too. Just like myself when I was employed, they have products to deliver and they have family and kids and they cannot always sit in front of the computer during their spare time. How could they find time to enrich themselves? How could they grow their skill and advance their career while serving the needs of their employer? Where did they find the time to research and blog about their research ?

Then I ran into this statement by Juval Lowy, a highly respected developer:

I think you have to be a professional developer. I think you have to understand that you have spent part of your time honing your skills, it's an ongoing life goal. It doesn't stop because you learn one thing, there is going to be changes. You should also search for a more nourishing business environment -- if they don't let you learn on the job [then] it's probably not the best place to work for.

Seriously I mean, the rate of change today is such that learning is part of the job. No ifs, no buts, that's the way it is.

Hah! That's it. If the place you work for just doesn't allow you to explore new things, you just won't get it. And if the culture in the workplace is against exploring new things, the innovation just won't thrive and all your poor souls just going to wither out like dry lily.

FIND A RIGHT PLACE TO WORK THAT IS HOW YOU GET AHEAD.

But how?

  1. Only join a company that seeks to hire best. Even if you don't think you are the best, by all means, give it a try. When you work day in and day out with the best, you grow every day. Human beings are products of environment.
  2. Only join a company that is the best in its niche. Good won't cut it. It has to be the great.


Wednesday, June 04, 2008

Book Review Peopleware: Productive project and teams by Tom DeMarco and Timothy Lister

How do I know about it: Joel Spolsky gave the booka glowing recommendation on his blog. Being a fan of Joel, I bought a copy.

Content:
The book is divided into five parts. Part 1: Managing the human resources, there are six chapters. Chapter 1: Somewhere today, a project is failing. Chapter 2: Make a cheeseburger, sell a cheeseburger. Chapter 3: Vienna waits for you. Chapter 4: Quality-If time permits. Chapter 5: Parkison's law revisited. Chapter 6: laetrile. Part 2: The office environment has seven chapters and one intermezzo. Chapter 7: The furniture police. Chapter 8: "You never get anything done around here". Chapter 9: Saving money on space. Intermezzo(according to the book,"an intermezzo is a fanciful digression inserted between the pages of an otherwise serious work"): Productivity measurement and unidentified flying objects. Chapter 10: Brain time versus body time. Chapter 11: The telephone. Chapter 12: Bring back the door. Chapter 13: Taking umbrella steps. Part 3: The right people has four chapters. Chapter 14: The hornblower factor. Chapter 15: Hiring a juggler. Chapter 16: Happy to be here. Chapter 17: The self-healing system. Part 4: Growing productive teams has six chapters, chapter 18: The whole is greater than the sum of the parts. Chapter 19: The black team. Chapter 20: Teamicide. Chapter 21: A spaghetti dinner. Chapter 22: Open kimono. Chapter 23: Chemistry for team formation. Part 5: It is supposed to be fun to work here has three chapters, chapter 24: Chaos and order. Chapter 25: Free electrons, chapter 26: Holgar Dansk.

What I like: It is a small book, with total of 188 pages and twenty six chapters. That puts average of 7 pages per chapter. The longest chapter is 12 pages and shortest one is 3. With short chapter, it is easier on readers concentration span. On the other hand, it puts high demands on author to deliver points efficiently. Overall, this book delivers. I feel I take home a clear message from each chapter. In terms of content, the book brought back a lot of dreaded memory of my previous project experience and shed a light on them. One now-defunct start-up I worked for before, the CTO went through a product design meeting with us engineers and wrote down the time needed on the whiteboard, then set a deadline that reduced the development time by one fifth. Guess what, the product was delivered overdue with a lot of bugs in them, and the whole engineering team had to be brought to the support side to fix the problem (at meantime making more bugs along the way). And years after the company imploded, I found the answer in the book.

What I dislike: None.

Quotables: "Quality, far beyond that required by the end user, is a means to higher productivity." "Quality is free, but only to those who are willing to pay heavily for it." "The one thing that all the best organization shares is a preoccupation with being the best." And I especially like the authors quoting of "Vienna waits for you" by Billy Joel, oh, those good old days J