Patrick\’s Bytes

1, December 2008

My new blog address

In case you drop by here. Do check out my new blog site at http://patrickyong.net

I will stop posting at this side.

1, July 2008

Microsoft Open Specification v1.0 released

Filed under: .NET Programming,Exchange,Office,Sharepoint,SQL Server,WCF,WPF — patrickyong @ 8:49 am

Awhile ago I blogged about Microsoft releasing products protocol documentation which are essential design specifications. That was about 2 months ago and the documents are of beta version.

Today the official version 1 is out that it covers the following products.

  1. Windows
  2. WCF
  3. Windows Server Protocol
  4. .NET Framework
  5. Office
  6. Office Binary File Format
  7. SharePoint
  8. Exchange
  9. SQL Server
  10. VBA Language Spec
  11. XAML

26, June 2008

IssueTracker 3.5 started on Codeplex

Filed under: .NET Programming,S+S — patrickyong @ 1:18 am

Base on the idea behind the Issue Tracker project in www.asp.net, I am developing a new version with the intention of

  1. To help people to sump start .NET 3.5 development
  2. To help people to jump start an application based on the S+S vision
  3. To serve as a base of the future Start.NET course I plan to write

I got the help of Poh Sze and Ervin to help me on part of the project and I hope to showcase it in Tech.Ed SEA 2008.

19, June 2008

Workflow Foundation and LINQ2SQL: Of BinaryFormatter and DataContractSerializer

Filed under: LINQ to SQL,Windows Workflow Foundation — patrickyong @ 12:44 am

There seem to be quite a lot of questions in forums and blog post about inability of have LINQ to SQL object in a Workflow Foundation’s Activity execution. Most of the time, you will end up getting a error message as below

Type ‘System.Data.Linq.ChangeTracker+StandardChangeTracker’ in Assembly ‘System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ is not marked as serializable.

After I did some research and found out about serialization method in LINQ to SQL here:

http://msdn.microsoft.com/en-us/library/bb386929.aspx

Code generation in LINQ to SQL supports DataContractSerializer serialization. It does not support XmlObjectSerializer or BinaryFormatter. For more information, see Serialization (LINQ to SQL).

However for Workflow Foundation, it is using BinaryFormatter to serialize objects into persistent layer (refer the MSDN document here)

When the workflow runtime encounters a persistence point during workflow instance execution, it calls the persistence service to do the work. The persistence service will then serialize the workflow state into a stream using BinaryFormatter serialization, optionally compress it, and save it into a durable store.

As such there is a crash here which renders LINQ to SQL entities can’t be used in Workflow Foundation. Fortunately Serena Yeoh found a solution and put it into her project at Layer Sample. You can found out more at this forum thread. Basically her code will take LINQ to SQL objects, clone it and serialize it using DataContractSerializer first before committing changes. Then after that it will return the cloned copy.

16, June 2008

Layered Architecture Sample for .NET

Filed under: .NET Programming,LINQ,S+S — patrickyong @ 10:28 am

Call it layered of n-tier also can, Serena Yeoh aka Firedancer who now works in Microsoft Consulting Services came out with a sample application based on the whitepaper – Application Architecture for .NET: Designing Applications and Services.

It is hosted at Codeplex and now at its 4th release. Besides demo how to built enterprise level application using .NET, it also features new cutting edge .NET 3.5 technologies such as LINQ, WPF, WCF and WF. By basing on the best practices of the MSDN Architecture whitepaper, this Expense Sample app also showcase and helps you to jumpstart SOA and S+S based architecture.

Again, here is the link

http://www.codeplex.com/LayerSample

3, June 2008

Getting Started with .NET @MCSB, Penang

Filed under: .NET Programming — patrickyong @ 9:19 am

Using the latest materials from Ervin to teach Getting Started with .NET for Start.NET program today at MCSB training center at Island Plaza, Penang. The first shock early morning is almost all the Visual Studio 2008 installation complain about trial expiration. I taken about 2 hours to figure out actually some itchy hands changed the system date of the training PC back to year 2007, thus triggering the VPC to complain about expiration.

Finished 4 out of 8 labs today and materials from Ervin are generally good and easy to understand but I realize a few places where it will do good to have some extra explanation. So on the spot during the training, I came out with a PPTX of about 7 slides to give examples on Object Oriented programming concept.

You can download it from SkyDrive here.

 image

30, May 2008

What’s up? Going to Penang next week.

Filed under: .NET Programming,Visual Studio 2008 — patrickyong @ 2:46 pm

I am out of KL for this week and will be running some workshops and talks at Penang.

This coming Monday and Tuesday I will conduct a Getting Start with .NET programming workshop at MCSB Training Center at Island Plaza. With the help of my pal Ervin Loh, he updated the content of the workshop to use latest features from .NET Framework 3.5 and hands on labs are using Visual Studio 2008. My colleague Rahimah will also be running similar workshop at Cyberjaya at the same place.

image

After that on next Thursday I will do a What’s new with Visual Studio 2008 talk at Penang Skills Development Center, expect something cool to be demo.

image

27, May 2008

Replace content of <w:t> element inside Content Controls with data bound value from Custom XML part

Filed under: LINQ,OpenXML,Word — patrickyong @ 4:47 pm

In my previous post I discovered that Content Controls in WordprocessingML files which has data binding to a CustomXML part will not render properly. However, this ONLY apply if you programmatically replaces the CustomXML part but never modify the value of <w:t> within the <w:sdt> element just like in this Eric White’s video on YouTube or as per mentioned in the book [Pro SharePoint Solution Development] in Chapter 7 .

To make things clearer, lets look at the screen shots below. For a Word 2007 document with CustomXML data bound(AND also with the CustomXML modified programmatically), below is what it looks like by default when you open it with Office 2003 (or XP and 2000), the data does not appear (below).

image

Even though you see there is no problem when open it up with Office 2007 (below)

image

This is because the Compatibility Pack for Office 2007 File Format does not render the value data bound inside the <w:databinding> element but instead its take the value in <w:t> element, shown below:

<w:sdt>
– <w:sdtPr>
<w:dataBinding w:xpath=”/root[1]/name[1]” w:storeItemID=”{b6aa39be-c6d5-40ca-a66e-93dbd069104f}” />
  <w:id w:val=”3411243″ />
– <w:placeholder>
  <w:docPart w:val=”DefaultPlaceholder_22675703″ />
  </w:placeholder>
  <w:showingPlcHdr />
  <w:text />
  </w:sdtPr>
– <w:sdtContent>
– <w:p w:rsidR=”006D15FD” w:rsidRDefault=”00F43988″>
– <w:r w:rsidRPr=”00583873″>
– <w:rPr>
  <w:rStyle w:val=”PlaceholderText” />
  </w:rPr>
<w:t>Click here to enter text.</w:t>
  </w:r>
  </w:p>
  </w:sdtContent>
  </w:sdt>

So I created a generic project using the latest OpenXML SDK (April 08 CTP) and together with LINQ to XML to modify the content within <w:t> element with the value from the CustomXML part. You can download my full source code here, but basically this is how my solution works:

XNamespace w = @”http://schemas.openxmlformats.org/wordprocessingml/2006/main”;

        public void Convert(string fileName)
        {
            using (var wordDoc = WordprocessingDocument.Open(fileName, true))
            {
                var mainPart = wordDoc.MainDocumentPart;

                XmlReader reader;

                reader = XmlReader.Create(mainPart.GetStream(FileMode.Open, FileAccess.Read));

                XDocument mainXml = XDocument.Load(reader);

                string xpath;
                XElement t;
                var bindings = mainXml.Descendants(w + “dataBinding”);

This is where the magic works, grab XPath attribute value from all the <w:databinding> elements and then replace it into <w:t> element using GetValueFromCustomXmlParts method (details do refer my source code)

                foreach (XElement binding in bindings)
                {
                    xpath = binding.Attribute(w + “xpath”).Value.ToString();

                    t = binding.Parent.Parent.Descendants(w + “t”).First();
                    string textValue = GetValueFromCustomXmlParts(mainPart.CustomXmlParts, xpath, myns);

                    t.ReplaceNodes(textValue);

                }

                XmlDocument temp = new XmlDocument();
                temp.Load(mainXml.CreateReader());
                temp.Save(wordDoc.MainDocumentPart.GetStream(FileMode.Create, FileAccess.Write));
            }
        }

After that the Word 2007 document can be opened in Office 2003 and data are rendered successfully. This solution also works in other none-MS Office productivity suites such as ThinkOffice and WordPerfect.

image

Disclamer: This is just a quick fix or rather a proof of concept on how to solve the <w:databinding> element problem on a simple Word 2007 document, there are  many situations (or more complex document layout) I haven’t tested the solution on. Do download my solution at your own risk. If you bump into problems do let me know, but my help will only be on best effort basis.

By the way, here is Eric’s video on the new OpenXML SDK

[YouTube=http://www.youtube.com/watch?v=t_FYHd234ng]
YouTube – Open XML SDK demo and road map

image

16, May 2008

Got DinnerNow working at last!!

Filed under: .NET Programming,S+S,SQL Server,Windows Server 2008 — patrickyong @ 8:09 am

DinnerNow is a cool sample application that is complex and huge enough to showcase all the latest Microsoft Windows Application Platform technologies. It is also a good example on how to put Software plus Service vision to work here. You can download the latest v2.5 version from Codeplex website.

Not I want to do selling here but the technologies includes

  1. .Net Framework 3.5
    • Windows Presentation Foundation
    • Windows Workflow Foundation
    • Windows Communication Foundation
    • Cardspace
  2. Windows Mobile 6
  3. MMC 3.0 shell addin developed using .NET
  4. Poweshell
  5. IIS 7.0
  6. Integration with Windows Live services such as Virtual Earth

Because of IIS 7.0, you will need to install DinnerNow on top of Windows Vista or Windows Server 2008. However since trying this for the past few months, I got no luck of getting it running. There has been quite a few posts on the Codeplex forum with people complaining the same time.

Then checking back all the event logs in the OS, I realize there are a lot of authentication error in the IIS log. This leads me to a creation the self signed SSL cert causes this problem. This is because when you setup the WCF service website of DinnerNow it will installs its own SSL cert as well. So for a change I created a clean Win Server 2008 VPC and during the IIS installation process, I refused to create or install any SSL cert. Just select Choose a certificate for SSL encryption later in the Choose a certificate for SSL encryption screen (as pic below)

image

Well, do check out whether this work for you or not which I believe there are other environment issues which might pops up for larger application like DinnerNow.

P/S: So to get DinnerNow working on my VPC, I installed the following software

  • Windows Server 2008
  • IIS 7.0
  • Visual Studio 2008 Pro with SQL Server 2005 Express
  • Powershell enabled
  • Desktop Experience enabled for WMDC
  • Windows Mobile Device Center (WMDC)
  • Windows Mobile 6 SDK

13, May 2008

.NET Framework 3.5 SP1 Beta and Visual Studio 2008 SP1 Beta out in the wild.

Filed under: .NET Programming,ASP.NET 3.5 Extension,Visual Studio 2008 — patrickyong @ 12:07 am

image image

Visual Studio 2008 together with .NET 3.5 was released about 1/2 year ago. However there are a host of planned features not able to make it to the release, for example:

  • ASP.NET 3.5 Enhancement Features
    • ASP.NET MVC (Model-View-Controller) Frameowrk
    • ADO.NET Data Service
    • Dynamic Data
    • Entity Framework
  • SQL Server 2008 CTP support
  • and more! Read up Scott Guthrie’s blog post.

.NET Client Profile

Then not long ago I got news that another new .NET features will make it to this SP1 release which is the .NET 3.5 Client Profile. Well, Windows Vista comes with .NET 3.0 but the world out there is mostly running Windows XP which does not have any.NET Framework installed at all! (unless you are  a geek head). The .NET Framework 3.5 Client Profile (BETA) contains a subset of features contained in the full installation of the .NET Framework. The subset of features are the Common Language Runtime, ClickOnce, Windows Forms, Windows Presentation Foundation and Windows Communication Foundation. Hollay!! Consider the fact that full .NET 3.5 requires .NET 2.0 and 3.0 installed then those 2 package already take up >100mb of downloads. You can check out Scott Guthrie’s blog here. http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx

Web Install Only

The Beta bits is available as a web install but there was ways for you to download everything and save them locally. Check out this knowledge base article. http://support.microsoft.com/kb/945140

Update Details

There are a few KB articles out there listing down all the changes

  1. VSTO http://support.microsoft.com/kb/949258  | http://blogs.msdn.com/vsto/
  2. Visual Studio Team System http://support.microsoft.com/kb/951845
  3. C# http://support.microsoft.com/kb/950263
  4. Visual Basic http://support.microsoft.com/kb/950264
  5. ASP.NET/Visual Web Developer http://support.microsoft.com/kb/950261
  6. .NET Framework http://support.microsoft.com/kb/951847

Download here!

You can download the bits here

Next Page »

Blog at WordPress.com.