John's profileJohn Liu .NET: Time for ...PhotosBlogLists Tools Help

John Liu

Occupation
Location
Interests
Software Developer, Architect, Consultant

John Liu .NET: Time for Fun in .NET

has moved to http://johnliu.net

Leaving Windows Live Spaces for SquareSpace

Finally packed up my stuff and getting ready to leave Windows Live Spaces.  After four years of blogging here, I’ve decided to resurrect my own domain and continue there.

NEW HOME HERE:  http://johnliu.net

JohnLiuNET

Figure: clean new website http://johnliu.net

 

Why the sudden change?  Didn’t you try this before and gave up? (2007 running my own web server at home…  not fun).

Well… truth of the matter is – Windows Live is great for a free solution, but the tweaks that I wanted to do, and can’t were continually giving me grief.

 

I ended up wanting to pay for a service where I can have more flexibility, without the maintenance headaches of running my own servers, and hopefully not too expensive.

I found such a solution at SquareSpace – so I’m moving.

A web dev joke…  if I could do a 301 Permanent Redirect here, I would.  But you know this is Windows Live Spaces…

 

First blog entry at the new home will be about the great Migration of data from Windows Live Spaces to SquareSpace.  If you want to learn about how to get your data out of Windows Live Spaces, you will have to follow me there.

 

Signing out - jliu

SharePoint: Groove assimilated by the Borg (aka SharePoint)

Prepare to be assimilated by the Borg.

http://blogs.msdn.com/groove_development_team/archive/2009/05/13/makeover-for-groove-sharepoint-workspace-2010.aspx

...Groove is getting a new name as of the coming release of Office 2010. Please welcome SharePoint Workspace 2010!

The name makeover is in concert with the direction the product is going. SharePoint Workspace will provide easy access to SharePoint content (or content from any server that implements the publicly documented protocols) in an effort to provide a seamless online/offline experience.

 

Groove SharePoint Workspace and OneNote will appear in Office 2010 Professional Plus (yes that’s the name... it’s a bit ridiculous).

Regardless, Groove has always been a pretty niche product – people that have used it liked it. Other people didn’t understand what it did. Now that it gets this re-branding I think there will be a lot more interest in this product and the offline capabilities. Good move on MS.

My colleague Marlon always complains to me that he can’t get his docs from SharePoint when we put our SharePoint on maintenance...  I’m sure he’ll be happier now.

 

jliu

SharePoint - service pack 2 thoughts

SharePoint service pack 2 came out a couple of days ago, for some reason I was really excited about it and even woke up checking twitter regarding any news…  It was surprisingly empty.

Anyway, over the last couple of days I’ve had a good whirl and here’s some thoughts – both mine, and heard over the grapevine.

 

Authentication — Improvements to forms-based authentication, authentication for Web applications, and the Business Data Catalog.

MSDN is saying that when Forms authentication is used SharePoint “should” do a better job at letting client (Browser) remember the password.

I’m hoping this means I don’t need to re-enter my password a billion times.

 

Database performance and integrity — Improved database performance and integrity by automatically rebuilding database indexes with a timer job. 

Self checks are good

 

Interoperability — Improved support for standards-based document formats and compatibility with a broader range of browsers level 1 and level 2 browser support.

IE8 enters level 1 browser support – the rich text editing should get fixed

FireFox2/3 enters level 2 browser support

 

Read-only content databases — Improved user experience by automatically configuring site collections as read-only when the content database is configured as read-only.

Again a good thing

 

Stsadm command-line tool — In addition to operations for pre-upgrade scanning and variations analysis and repair, several operations are improved and new operations added to better support farm administration.

stsadm –o backup will now issue a stsadm –o setsitelock prior to the backup, unless otherwise stated.

This means that sharepoint administrators no longer need to do this in two steps.

stsadm –o deletesite now supports a force argument that allows orphaned site collections or orphaned sites to be deleted.  Only time I’ve seen an orphan site is when we had a bad import that failed halfway.

 

Pre-upgrade scanning and reporting — An Stsadm operation that enables you to scan an existing farm and its servers to verify that they can be upgraded SharePoint Products and Technologies "14".

stsadm -o preupgradecheck

is only to check against future versions of SharePoint 2010.

 

Variations analysis and repair — An Stsadm operation that enables farm administrators to better manage and perform necessary operations against variations.

There’s a quite bit of work for variations.  This isn’t an area where I’ve had a lot of experience.

 

Merge Content DB bug fixed

Yay

 

Breaking Changes:

Areas web service removed

There’s some impact to Nintex Workflows – there’s an interim fix that they’ve released, as well as a patch coming out within a week.

IIS7 WCF .SVC 404

This is a tip for myself:

For the weird reasons I could not understand – if your IIS7/Vista doesn’t have a handler for .svc all of a sudden – you can re-register them using the following registration.

I’m still not sure why this suddenly stopped working :-(

 

"C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y

SharePoint - On the verge of launching a new release of a SharePoint site

On the verge of launching a new release of a public SharePoint website and I came across this list (from shanselman’s twitter actually).

15 Essential Checks Before Launching Your Website

Here’s how we fared:

  1. Favicon checked and done!
  2. Titles and Meta data checked!  Actually SharePoint comes with quite a bit of baggage, but we started with a clean masterpage so this is not too bad.
  3. Cross-Browser Checkschecked!  IE6, 7, 8, FireFox, Chrome, Safari + iPhone.  RichHTML editing is limited to IE for now – but there’s a release soon afterwards to upgrade to Telerik’s RadEditor Lite.
  4. Proofreadnot enough :-(
  5. Linkschecked - using both SharePoint’s internal reports and SSW Link Auditor – hopefully the content editors don’t put in bad links from now til launch…
  6. Functionality Checkchecked!  My biggest fears are that in the sprint until launch, if we accidentally break an existing feature that was working previously, so far my fears have been unfounded.
  7. Graceful Degradationnot checked…  I think I’m going to feel guilty for saying this one, but I just don’t think it’s relevant to check for JavaScript now.  Especially on a SharePoint site.
  8. Validationno - it’s SharePoint.  This is going to be a tough one to tick off.
  9. RSS Linkchecked – may be.  One of the features of this release, unless we have to cut it.
  10. Analyticschecked – both the SharePoint reports, as well as Google Analytics that was used for the old site
  11. Sitemapchecked – SharePoint does this naturally
  12. Defensive Designchecked.  SharePoint allows for 404 to be customized
  13. Optimizenot enough.  We’re utilizing quite a few performance tricks we have up our sleeves, but ultimately there’s just not the level of control in SharePoint vs. say a custom ASP.NET application
  14. Back Upchecked
  15. Print Style Sheetneed to check again.  This was working previously but we’ve had some work done on the site in the last two releases and I’m a bit worried about our good ol’ print css.

 

So we scored 10/15.  Ticked off most of the easy ones.  Have quite a few really tough ones left.  Wish us luck!

SharePoint – thoughts on MSDN “Configuring and Deploying Anonymous Publishing Sites for SharePoint Server 2007”

Andrew Connell’s white paper on Configuring and Deploying Anonymous Publishing Sites for SharePoint Server 2007 just went up on MSDN.

The following are my thoughts in detail.  For the most part – I agree with the views presented in the white paper, and I believe the white paper covered at a glance many of the crucial aspects of anonymous publishing.

Some of these points I wanted to further elaborate and explain some of my own experiences and/or approaches that I’ve found to work better.

 

Limiting the Page Payload

Fiddler is great.  FireFox’s FireBug also serves a similar purpose.  You want to try to reduce the number of files that are sent across.  Reducing CSS, core.js, core.css will go a long way to reduce the page payload.

I’ve found HttpModule to be far better at stripping core.js, core.css and much of the unused form hidden fields from the output.  Need a lot of testing though.

In addition – check out YSlow FireFox add-in.  Which discusses issues such as E-Tags not being set properly in IIS – you might as well turn it off and let browsers determine file base on modified date / size.

Managing the Name ActiveX Control

This is related to my earlier blog SharePoint – Name ActiveX Control error.  I discussed the circumstances on why this ActiveX control is appearing, what does it do, and why does it only give you grief when running in the Internet Zone on IE.

While the Mossman Way works – I prefer using a HttpModule.

Anyway – I thought if Person Name Smart Tag and Presence Settings is switched off via Central Administration this would have gone away (mentioned later in the white paper).  UPDATE - tested this doesn't work - while the setting is off it still asks for the Active-X

Taking Advantage of Custom CAS Policies for Custom Code

Use CAS policies so you can keep to WSS_Minimal.

Many of our assemblies are deployed in the GAC which runs in full trust.  The reason we put them in the GAC is more a decision related to solution package deployment, and not from a security point of view.

Configuring a SharePoint Site Collection or Site

Blocking Users from Seeing All Pages in a SharePoint Publishing Site

ViewFormPagesLockdown is absolutely necessary.  I’m so glad it’s mentioned in this white paper.

Enabling and Configuring Caching

page output caching and object caching are mentioned – both are very useful.  Page Output caching for the anonymous profile is necessary to achieve high performance from a public site.  Remember to switch on the comment so you can catch caching issues from your staging and production servers.

blob caching is not mentioned – I’m not sure the reasons, but I’ve found it to be useful but I have seen the blob cache rendering and cropping only half of the CSS file that I have.  Is that a SharePoint bug?  Hard to say.  I found some blog articles that asked the same questions – blob caching is one of those supposedly-low-risk-high-gain performance configurations that you can do, but I ended up with only use blob caching with sufficient testing.

Configuring a SharePoint Web Application

Disabling User Presence Information

Just echoing this – I think this should stop the ActiveX presence “name.dll” appearing on IE when you stop this.

UPDATE - tested this doesn't work - while the setting is off it still asks for the Active-X

Disabling the Blog API

Disabling Incoming E-Mail

Separating Content Between Authoring and Production Environments

I noticed I stopped commenting much towards the end of the article.  It was good to see publishing content deployment being discussed at the end - great article.

SharePoint – IE8 standards mode causes trouble in SharePoint

Running SharePoint on IE8 – JavaScript errors when using the rich text editor.

‘null’ is null or not an object – in form.js

clip_image002

 

The debugger shows that the SharePoint javascript code was trying to call:

document.getElementById("ctl00_PlaceHolderMain_EditModePanel3_ctl04_ctl00_RichHtmlField_displayContent_LTR")

The id of that element is actually: ctl00_PlaceHolderMain_EditModePanel3_ctl04_ctl00_RichHtmlField_displayContent_ltr

In IE7’s incorrect JavaScript behavior – it finds the element and returns it.

In IE8’s correct JavaScript behavior – it doesn’t find the element and returns null.  -> Error!

---

IE8 will attempt to use IE7 compatibility mode when accessing intranet sites.  It will use IE8 standards mode when accessing public internet sites.

This means that when accessing your SharePoint site via the extranet URL – http://sharepoint.company.com/ you will get this error, but accessing it internally – http://sharepoint/ will be OK.

----

Ways to fix this (easy to hard):

  1. Custom Header in web.config (site-wide)
    http://msdn.microsoft.com/en-us/library/cc817572.aspx
  2. Meta tag in master page (specify per masterpage)
    http://msdn.microsoft.com/en-us/library/cc817574.aspx 
  3. Use Telerik’s RadEditor Lite – free alternative
    http://www.telerik.com/products/aspnet-ajax/sharepoint.aspx
  4. Wait for MS SharePoint hotfix
    UPDATE: waiting for MOSS service pack 2 - which contains IE8 support
  5. UPDATE: tell your editors to run SharePoint in compatibility mode

So you want to be a SharePoint architect

Someone asked what is a SharePoint architect:

http://stackoverflow.com/questions/654318/what-knowledge-should-a-software-architect-have-about-sharepoint/

Here’re my thoughts collected and reposted (and most likely incomplete):

 

Skills such as list, documents, workflow, permissions... are a bit too basic and are requirement for a SharePoint DEVELOPER.

I'd argue that perhaps site (and site structure) is an area that would fall under the architect's plate.

There are more areas that a SharePoint architect can help with:

  • Capacity planning - running multiple servers in a farm. Scalability and other magic words.

  • Knowing the capabilities and business scenarios of using SharePoint - this is a very common one.
    The manager asks: what can SharePoint do for me? The developer asks: well, what do you want it to do. The manager then asks: well, I don't know what it can do for me so how do I know what do I want it to do?

  • Closely related to SharePoint capabilities are the various licensing costs related to each component.

  • As well as familiarity with development and customization costs. Take the same project time that would have taken in ASP.NET, then multiply it by a large coefficient, and then add an additional constant.

  • And closely related to what-can-it-do, and how-much-does-it-cost, is the all important question of Return-Of-Investment. All hail supreme ROI!

  • SharePoint deployment can be a massive issue and a lot of pain.

  • SharePoint upgrade from v2 (MOSS 2003) to v3 (MOSS 2007). We should be seeing a new version of SharePoint in 2010(?). Well soon after the next version of Office goes out the door. So past upgrade experiences may be useful.

  • Knowledge of 3rd party webparts. I believe a SharePoint architect should be able to give you at least 5 webparts that they've tried from CodePlex and tell you what they think about them. These are free and easy to grab and play at your own leisure.

  • Some knowledge of commercial webparts. Because they are still cheaper than writing your own.

  • Have at least 5 SharePoint blogs that they follow religiously (know the community). If not having their own SharePoint blog (give back to the community).

  • If they are on StackOverflow they must try to answer SharePoint questions (such as this one).

  • Attend local SharePoint usergroups. I think communities are a huge deal. Especially what you'd learn from talking with people directly and learning what they are doing with their SharePoint installation. You may just surprise yourself.

  • Experiences with SharePoint Integration - this comes in two equally important flavours - both from SharePoint accessing existing systems (business catalogs, webparts, etc), as well as other systems accessing SharePoint content via webservice or API.

  • In addition, SharePoint works with (or works well) with Office, OCS, reporting services, performance point, project server.

  • SharePoint hosting arrangements - Microsoft SharePoint online services can be a popular and cheaper option to start using SharePoint. It can be hosted inhouse, or with a 3rd party company. Knowing the options is always useful.

  • Must have read SharePoint code using reflector (and preferably still having hair).

I think it takes at least a couple of years to be a SharePoint architect (your mileage may differ). Your .NET architects need to want-to-be a SharePoint architect, otherwise I agree with other's summaries before me - find someone who already is a SharePoint architect.

Bad Microsoft (System.Web) code got owned by StackOverflow

Here’s an amazing question asked by Diadistis on StackOverflow.

http://stackoverflow.com/questions/653730/gc-collect-in-a-loop

Won’t go into details you got to read it if you are interested.

SharePoint – Name ActiveX Control error.

image

 

This error pops up on SharePoint MOSS publishing websites that are in the Internet security zone for IE browsers.

This is because the core.js file wants to use ActiveX control “name.dll”, this ActiveX control is responsible for the presence information for SharePoint.

In the Internet security zone, IE pops this question to the user to ask them whether they want the ActiveX to run.

In development

For developers, if you have accidentally clicked “Yes Allow it to run”, then you won’t see this error and it can hinder your debugging of your public SharePoint site.

This is a RegEdit fix to get rid of this key to see name.dlll ActiveX warning in IE again.

HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{E18FEC31-2EA1-49A2-A7A6-902DC0D1FF05}

I have been told that some server machines doesn’t seem to have this key.

UPDATE try: HKCU\Software\Microsoft\Windows\CurrentVersion\Ext\Stats\{E18FEC31-2EA1-49A2-A7A6-902DC0D1FF05}

Fix

  1. MS has a KB article that shows you a broken way of fixing this.  It doesn’t work.
  2. We’ve found two other ways that are slightly better, one way is to override the JavaScript function that calls this – you have to be careful of the timing of which events are called first.
  3. The other way is to implement a HTTP output module to strip the reference to core.js from the output stream.  This can only be done safely for anonymous users, as core.js contains required JavaScript that is necessary for content editing.

Javascript - jQuery + ASP.NET – post-AJAX events

From jQuery, we get $(document).ready which is wonderful.
From ASP.NET, we get the UpdatePanel control which is fantastic.

 

One of the common problems that people have is regarding how to re-run the scripts after the UpdatePanel ajax update.

Here is one javascript-based solution – I consider these less intrusive than the code-behind solution with ClientScript.

Disclaimer – I learn this from previous projects I’ve worked on with personal experimentation – but I have not since read much documentation.

 

Original:

$(document).ready( function() {
    $("a.link").css("border", "1px solid red");
})

The improved:

function setupLinkBorder( parentElement ) {
    $("a.link", parentElement).css("border", "1px solid red");
}
$(document).ready( function() {
    if (Sys && 
        Sys.WebForms && 
        Sys.WebForms.PageRequestManager && 
        Sys.WebForms.PageRequestManager.getInstance()) {
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function(src,args){
setupLinkBorder(args.get_panelsCreated()); // when UpdatePanel are first loaded
setupLinkBorder(args.get_panelsUpdated()); // when UpdatePanel are loaded via AJAX }); } })
  1. Split out the actual script into a separate function
  2. Make sure you have a Sys.WebForms.PageRequestManager.getInstance() object – the code for this part was a bit scary.
  3. Add event handler to handle pageloaded event fired by ASP.NET (which occurs for UpdatePanel update as well)
  4. Rely on the parent element property of jQuery to limit jQuery selector to elements within the updated panel only.  This ensures you don’t fire the jQuery code on elements that are outside of the UpdatePanel – which can be bad.

re: Dell Newsletter

After reading yet another Dell monthly newsletter, I decided to reply to it.  I figure it’s rant-worthy.

Hi Mr Dell,

When I purchased my laptop, I was after a couple of spare 9-cell battery for longer battery life, and I was told it was out of stock, which is fair enough – these things go out of stock from time to time.

I specifically left instructions that when they are in stock, I would like to be notified.

Because I _really_ want them.

It has since been 6 months, and I find it hard to believe that they are still out of stock.

I think it’s good customer relationship management to:

1. give me an update on what's going on

2. you may need to fix your CRM software, because I think these are simple instructions that should have been followed up on at least every 3 months - especially since the customer is already telling you he wants to spend the money

3. you should already know which laptop model that I bought from you, and that which I've specifically told the sales girl to put down a note that I want the better batteries for this laptop.

jliu

SharePoint - Cannot get ghost document

We chased a fun bug in the afternoon after we deployed our new package to our staging server.

Symptom:

Our customized Content Query Web Parts stops rendering.
But we noticed they were still functioning when we drop into edit mode.

Hint:

This gave us the hint that our XSL was probably stuffed – but it checked out ok in SharePoint designer*.

Detective Work:

Digging through the SharePoint logs, we came across two lines that are incredibly suspicious:

0x17C4    Windows SharePoint Services       Web Parts                         89a1    Monitorable    Error while executing web part: System.Xml.Xsl.XslLoadException: XSLT compile error. An error occurred at (1,482). ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.     at System.Net.HttpWebRequest.GetResponse()     at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)     at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)     at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)     at Microsoft.SharePoint.WebPartPages.WSSXmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)     at System.Xml.Xsl.Xslt.XsltLoader.CreateReader(Uri uri, XmlResolver xmlResolver)     at System.Xml.Xsl.Xslt.XsltLoader.LoadStylesheet(Uri uri, Boolean include...    

0x17C4    Windows SharePoint Services       General                           72ks    Medium      Cannot get ghost document:

Features\blah\blah.xsl    

Story:

The path to the XSL was familiar, and the problem immediately became apparent.  It was the old path, we’ve since re-organized our deployment package, and that old path to the xsl file no longer works.

The Fix:

Drop into Style Library\ and delete all the XSL files that are ghosted.
Deactivate and reactivate the XSL feature so they get re-ghosted.

Notes:

SharePoint designer must have cached the file at some point, so it was happily showing us a copy of the file while in reality due to our re-organization of the feature it wasn’t actually available anymore.

Re-organizing feature package always has hidden costs…

SharePoint – for those times when you really got to kill a list

This is a simple tip

So the list template stuffed up a list and you can’t get to it in “site library and lists”

The backdoor way to remove the list is:

stsadm -o forcedeletelist -url http://server/Lists/list-name

http://technet.microsoft.com/en-us/library/cc262609.aspx

The new flood of stuff coming out of Windows Live are really nice

I do have FriendFeed, but I think too little people know about FriendFeed (http://friendfeed.com/johnnliu) - but it's a very techy solution.  I think Windows Live's offerings will reach more people quicker.

Anyway,

It's already hooked to to my blog, MSN messenger

I've got 2 web activities enabled:

Flickr
Twitter

still waiting for a few more web activities to become enabled:

digg
youtube
facebook

Theoretically I can just use the RSS feed from these, but I want to see what additional features I get for 'integration'.

Also, when people comment on my windows live feed, I'd like to see it in MSN messenger.

Anyway, waiting :)

SharePoint - ContentQueryWebPart, CommonViewFields and Multi-value choices

When you add a choice or lookup to the CommonViewField for a ContentQueryWebPart, if you had ticked the allow multiple-values checkbox, the CQWP will return you nothing.

Couple of people blogged about this:

http://sridharu.blogspot.com/2008/05/content-query-webpart-customization.html

http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx

Adri Verlaan [MSFT] even says:

Unfortunatly the data source that the CQWP uses does not support Mutli-Valued Lookups or Multi-Choice columns.

 

Turns out after a bit more digging around, you _can_ use multi-value choices.  To get multi-value choices to work, you need to use a different type:

Instead of Choice, use MultiChoice

<property name="CommonViewFields" type="string">MyDescription,PublishingHtml;MyTags,MultiChoice</property>

I have not had much luck with Multi-lookup and I suspect there might be some truth in what Adri was referring to.  If I consider how SharePoint might have to work with a field that contains multiple keys to a different lookup list, this problem becomes far more complex.

Anyway, at least it works for choice.

Have fun!

jliu

Lemmings 4D game

I'm pretty sure Lemmings stopped at 3D.  But I think there's room to make a 4D game:

 

Implement in SilverLight

- Utilize the harddrive

- add special tools that are time based

- add time-warp portals

Windows Live configuration sync

I had this idea that popped up when I was listening to the current .NET Rocks - The Future of Web Development Panel.  I was listening to the panel lamenting about having to manually configure their development environment per machine that they use and thought, geez surely this can be solved perfectly with Windows Live.

Sure enough, within minutes of this idea popping in my head, one of the guys on the panel stated this, and got overwhelming applause.

That is one great idea.

So, you have Windows Live Mesh right now.  You can sync files, links and photos online.  How hard would it be to synchronize Visual Studio settings, office settings / templates, browser settings, etc etc

Taking the idea further, there is a set of tools you always use for your machine - wouldn't it be nice if you can re-use a license key (if it allows) across all your machines and share them via a Live Mesh account.

Or even when you build a new machine, a Life Mesh application automatically asks you if you want to re-install all your favourite tools that you had on your previous machine - tells you if it has a newer version (say for windows 7), and / or any driver requirements.

When you say "yes please", it will install these for you at a convenient time - AND copy your configuration settings so it'll behave JUST THE WAY you had it set up before!

Throw in some integration with Microsoft Online Store...

I can't stop drooling.  If someone don't build this app soon I will!

It is so great to live in a Software + Service world!  These are great times!

I twit now (oh and I still blog)

I'm sorry I'm probably very very late to the bandwagon, but there's a few reasons for this:

  1. Just ain't very keen to login to Facebook all the time to just update a status
  2. I know twitter had been the thing...  I'm trying to redeem myself
  3. Was at powertodevelopers event, when everyone was whipping out their iPhone / windows mobile to twit, I didn't have an account so it was a bit embarrassing
  4. Unless you twit you won't know what it's all about...

Anyway, follow johnnliu (double-n)

SharePoint: Error when adding a new page based on a customized (broken) page layout

Exception:

No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)  

image

Some interesting bits in the stack trace:

... at System.Activator.CreateInstance(Type type)

... at Microsoft.SharePoint.WebPartPages.SPWebPartSerializer.get_DefaultControl()

... at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)

snipped remaining massive stack trace.

What had happened was that we had a stuffed up Page Layout with a web part zone that contained invalid HTML.

I had detected this and deleted the entire web part zone, but SharePoint must have it in the database, so each time I re-open the PageLayout it was resurrecting all the broken code.

The fix wasn't at all glamorous:

  1. Check out the page layout
  2. Fix it enough in the code view so that the designer will load the designer view
  3. Delete the webparts in the designer view
  4. Switch back to the code view - there's now a few remaining bits of broken HTML left around the web part zone - fix those.
  5. Save everything
  6. Close file, re-open it
  7. Check the file is now clean HTML

We can now use the page layout to create new pages again.

jliu

Didn't know it could be this difficult to pull something out of the GAC

So, a few days ago, one of my favorite TFS/Outlook add-on stopped working.

Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TeamFoundation.Client, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

image

Puzzled, I figure there's something odd with the Fusion loader.  Popping into the GAC I saw this horror!

image

I must have installed something that upgraded all the library to version 9.0.  OK, no problems, let me uninstall the old version 8...

Exception:
Assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client' could not be uninstalled because it is required by other applications.

image

A bit of reading lead me to this article.

GAC Assembly Trace Reference
http://blogs.msdn.com/junfeng/archive/2004/09/13/228651.aspx

 

Hitting gacutil to see what's referencing it...

c:\Program Files\Microsoft Visual Studio 9.0\VC>gacutil /lr Microsoft.TeamFoundation.WorkItemTracking.Client

Microsoft (R) .NET Global Assembly Cache Utility.  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  Microsoft.TeamFoundation.WorkItemTracking.Client, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86
              SCHEME: <WINDOWS_INSTALLER>  ID: <MSI>  DESCRIPTION : <Windows Installer>
  Microsoft.TeamFoundation.WorkItemTracking.Client, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86
              SCHEME: <WINDOWS_INSTALLER>  ID: <MSI>  DESCRIPTION : <Windows Installer>

Number of items = 2

Taking great care not to uninstall both versions, I'm being ultra cautious:

c:\Program Files\Microsoft Visual Studio 9.0\VC>gacutil /l "Microsoft.TeamFoundation.WorkItemTracking.Client, Version=8.0.0.0"

The Global Assembly Cache contains the following assemblies:
  Microsoft.TeamFoundation.WorkItemTracking.Client, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86

Number of items = 1

Ok... go crazy!

c:\Program Files\Microsoft Visual Studio 9.0\VC>gacutil /u "Microsoft.TeamFoundation.WorkItemTracking.Client, Version=8.0.0.0"
Microsoft (R) .NET Global Assembly Cache Utility.  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly: Microsoft.TeamFoundation.WorkItemTracking.Client, Version=8.0.0.0, Cul
ture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=x86
Unable to uninstall: assembly is required by one or more applications
Pending references:
              SCHEME: <WINDOWS_INSTALLER>  ID: <MSI>  DESCRIPTION : <Windows Installer>
Number of assemblies uninstalled = 0
Number of failures = 0

Not knowing the keys to run gacutil /ur, I turned and did more research:

This one is from the Fusion guys

http://blogs.msdn.com/alanshi/archive/2003/12/10/42690.aspx

I found two of the reference keys in the registry.  And exported them just to be safe.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Assemblies\Global]
"Microsoft.TeamFoundation.WorkItemTracking.Client,Version=\"8.0.0.0\",PublicKeyToken=\"b03f5f7f11d50a3a\",Culture=\"neutral\",RuntimeVersion=\"v2.0.50727\",processorArchitecture=\"X86\""=hex(7):65,\
  00,45,00,65,00,2b,00,48,00,25,00,65,00,30,00,78,00,40,00,45,00,59,00,7a,00,\
  4b,00,4c,00,2c,00,70,00,71,00,5e,00,41,00,3e,00,2e,00,32,00,2a,00,7d,00,66,\
  00,7b,00,40,00,35,00,49,00,3f,00,69,00,4a,00,68,00,67,00,78,00,59,00,7a,00,\
  7a,00,4c,00,2c,00,00,00,00,00
"Microsoft.TeamFoundation.Common,Version=\"8.0.0.0\",PublicKeyToken=\"b03f5f7f11d50a3a\",Culture=\"neutral\",RuntimeVersion=\"v2.0.50727\",processorArchitecture=\"X86\""=hex(7):65,\
  00,45,00,65,00,2b,00,48,00,25,00,65,00,30,00,78,00,40,00,45,00,59,00,7a,00,\
  4b,00,4c,00,2c,00,70,00,71,00,5e,00,41,00,3e,00,66,00,6c,00,45,00,37,00,36,\
  00,72,00,3f,00,47,00,34,00,3d,00,59,00,49,00,29,00,41,00,4c,00,71,00,5f,00,\
  5f,00,58,00,54,00,00,00,00,00

Then I dropped these trace references from the registry.

Head back to the GAC, uninstall the two offending Assemblies.

Pop back to Outlook.  Hey, my favorite addon works again.

:-)

Hope this helps someone out there.

jliu

Late blog (as in, not a live blog) Australia Power To Developers event

So there I was, sitting in the front row of the Power to Developers event in Sydney Convention Center.  A really great place by the way - it's like 5 minutes away from my home.

Steve Ballmer's presentation of Windows Azure is certainly very energetic.  He did the "Developers, Developers, Developers" chant - I cheered!

Gianpaolo Carraro's presentation on Windows Azure services was interesting, it certainly got my hands all itchy.  *Waiting for that SQL Data Services invite*

Tim Sneath's very excited about Windows 7, WPF and SilverLight.  I bumped into him outside the convention center and asked him about his visit to Sydney, in hindsight what I really should have asked him was which of these cool technologies should I spend all my time on?  How do I choose!

All the technical presentations were flaky, with the audience bursting out in laughter whenever Gianpaolo says "Oh Come On!"

I also got to meet heaps of people that I worked with over the last 3 years as well as some that were in SSW before that.

Shout outs:

the SSW crew,
David Klein, Adrian, Marlon
Ciprien, Ben Scott, Christian Maslen, Gordon Salier
Adelle, Peter

SharePoint, WCF Service, .NET full/partial trust

Security Exception: That assembly does not allow partially trusted callers

Scenario:

  1. We wanted our SharePoint webpart to do some complex logic that took time.
  2. We decided to implement it as an AJAX call to an AJAX WCF Service (see earlier post)
  3. To avoid cross-domain issues, we decided to host the WCF Service under SharePoint root.

The bigger picture looked like this:

  • SharePoint root: http://server/
  • WCF hosted on http://server/wcf.service/service.svc 
    Which we configure as a Web Application in IIS.
  • We build the WCF service separately and tested it to be working.
  • When we deployed to the SharePoint box however, we hit a snag when our WCF service calls an underlying API:

    Security Exception: That assembly does not allow partially trusted callers.

The cause:

What we understood of the problem basically was that the web.config for SharePoint http://server/web.config specified trust policies that mean anything under http://server/... was running with partial trust.

This isn't necessarily a bad thing, but because the API's we were calling demanded full trust, we couldn't proceed without granting the service full trust.

The fix:

There are many ways to grant the service full trust, we decided to do this by placing the service assembly into the GAC on the SharePoint server.

  1. Put assembly (strong-named) into the GAC
  2. Add <assembly> line into the web.config

If this option isn't available for you, check out caspol or the .NET configuration tools to elevate permission for your assembly.

Thoughts:

The deployment ended up to be very nice and tight:

SharePoint talks to the service via a SmartPart + jQuery.ajax

Done!

Windows Live Mail (Hotmail) has a nice new look

Most people probably have a Hotmail account, but like me, probably haven't visited it for quite a while.

Anyway, they unleashed a new version recently that looks a lot slicker.

(This is in Chrome)

image image

Very cool. 

I still think it misses the conversation threading view which is really fantastic in gmail, also I think tagging emails is still better than folders for organization.  But it's fast and snappy and doesn't require you to use IE for the full experience.

Consuming WCF WebService from jQuery AJAX (with JSON)

So the guys at work are pretty sold on jQuery now.  Everybody who've used it don't want to go back to vanilla JavaScript (just as I predicted).

One of the things always sitting at the back of my mind is to bridge the call from jQuery.ajax to WCF WebServices.

Finally we had a chance to do this, and it turns out this was pretty easy.  Special mention to Alvin Shen and Ron Maman who checked this out.

 

  1. Create an AJAX-enabled WCF WebService
    image
  2. This will update your web.config - the only difference is the WCF bindings used - here are the two interesting bits

    <service name="SSW.WCF.Services.BookService">
       <endpoint address="" behaviorConfiguration="SSW.WCF.Services.BookServiceAspNetAjaxEndPointBehavior"
        binding="webHttpBinding" contract="SSW.WCF.Services.BookService" />
    </service>

    <behaviors>
       <endpointBehaviors>
          <behavior name="SSW.WCF.Services.BookServiceAspNetAjaxEndPointBehavior">
             <enableWebScript />
          </behavior>
       </endpointBehaviors>
    </behavior>

  3. Here's the jQuery AJAX call

    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: http://localhost/<web app name>/BookingService.svc/DoWork,
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(data) {
                alert(data.d);

            }
        });
    });

 

Incredibly easy, the hardest part was working what the url was going to be

 

UPDATE technologies list:

  • jQuery
  • WCF WebService (AJAX-enabled WCF WebServices are only available in ASP.NET 3.5 - where they added the webHttpBinding, which does JSON serialization)

UPDATE:
Note that ASP.NET does date serialization a bit differently - there is no proper JSON date standard, and the JavaScript date doesn't match the .NET DateTime class with timezone, you may need to do a bit of work to serialize back to a JavaScript date. 

 

Here's a fun service that we use for testing.

// Add more operations here and mark them with [OperationContract]
[OperationContract]
public object[] TestJSON()
{
    return new object[] { DateTime.Now, 1, 1.034f, null, "test" };
}