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.