Right now I’m troubleshooting a mysterious error that one of my support customers is experiencing using InfoPath forms on a SharePoint site. The users are entering information into a browser enabled form, taking a really long time, and I’m pretty sure there’s a session timeout happening. What’s mysterious is that I can’t reproduce the error exactly by opening a form and letting the session time out, then attempting to save it. I get a completely different error. So there must be more at play.

My current working theory is that there are 2 separate (but possibly related) issues happening at the same time. One error when the user attempts to save the form (resulting in the loss of all their changes), and one when the browser attempts to reload/display it (resulting in the error message shown and the inability to go back to a view of the form with their updated content).

Here are some sanitised error messages I’ve captured from the event log when the problem happens.

InfoPath Forms Services has detected a mismatch between the user's data in the browser and on the server. This may indicate the SESSION_STATE_PASCAL_CASED is not configured properly on a multiple front end farm or that a malicious user is trying to tamper with client data. (User: DOMAIN\username, Form Name: Form, IP: , Request: http://website/_layouts/FormServer.aspx?XmlLocation=/filepath.xml&Source=http://website/Library/Forms/AllItems.aspx?RootFolder=%&FolderCTID=0x0120004AE5D17103937E4DAC784D461AF8C33D&View=%257b9AD631DA%252d5EDE%252d4EF1%252d8FF3%252d14ED56F1471A%257d&DefaultItemOpen=1, Form ID: urn:schemas-microsoft-com:office:infopath:Form:-myXSD-2009-09-01T01-30-36) 604f4e9e-bff3-460d-af19-229411e20ab9

WARNING: Invalid Canary for view file. StackTrace: at Microsoft.Office.InfoPath.Server.Controls.ResourcePage.GetSolutionAndVerifyCanary(HttpContext context, String solutionId, SPSite contextSite, ResourceErrorType& error) at Microsoft.Office.InfoPath.Server.Controls.ResourcePage.HandleViewFile(HttpContext context) at Microsoft.Office.InfoPath.Server.Controls.ResourcePage.<>c__DisplayClass2.b__0() at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock) at Microsoft.Office.InfoPath.Server.Controls.ResourcePage.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error) at S

Don’t you love how that last stack trace just gets cut off like that? Woo!

Here is my current link log from researching the issue:

My conclusion is that there is some type of caching, cookie expiry, session timeout bad juju going on. Unfortunately that’s not one I can document for an end user!

I know I’m going to need to use this again at some point & it took me an hour and a half to figure this one out. I can’t believe .NET 2.0 doesn’t have a built-in method to do this…?

// C#
public DateTime GetStartOfWeek(DateTime date, DayOfWeek WeekStartDay) {
double daysToStart = (Convert.ToDouble(today.DayOfWeek) - Convert.ToDouble(WeekStartDay) + 7) % 7;
DateTime weekStartDate = date.AddDays(0 - daysToStart);
return weekStartDate;

I reconnected a disconnected server to a SharePoint farm, and after the Configuration Wizard finished running, I checked the Services on Server page to verify that everything was OK and start up the Search and Excel services. Much to my consternation, the “Window SharePoint Services Web Application” service was stuck on “Starting” and none of my web applications had appeared in IIS. Argh.

Fortunately, Joel Oleson’s blog came to the rescue. The correct stsadm command to use to force this sucker to start is:

stsadm -o provisionservice -action start -servicetype SPWebService

It took a while for the command to complete, but that seemed to fix everything up nicely.

I know I’m going to need to read this shortly:

Deep Dive into the SharePoint Content Deployment and Migration API – Part 1

I am currently working on integrating some existing ASP.NET forms into the /_layouts/ folder in SharePoint as they will need to run in SharePoint context. These forms call web services using Microsoft’s Web Services Enhancements add-on. The add-on creates a config file with the WSE settings for your project, but it needs to be stored in the root of the web application, so you need to make sure to put a copy of this config file in the web root of the SharePoint site (e.g. c:\Inetpub\wwwroot\wss\VirtualDirectories\<site>).

Because I keep losing this link & keep needing to perform 800 searches to find it again, I am bookmarking it here:

SharePoint 2007 – /_layouts and how to create pages that run in site context – Serge van den Oever

It is also a very useful link if you are doing any kind of custom development that requires a custom “settings” type page (for instance, if you are writing a custom workflow without InfoPath to handle the forms).

I also found that you may need to install a hotfix on your Windows 2003 VPC in order to install SP1 for Visual Studio in order to get the web application project type mentioned in that blog post. The hard way. After wasting many valuable hours.

Online Map Technologies

12 August 2007

The current web site project I’m on has a requirement around using live maps for showing location information. On my last day at TechEd I sat in on a session on Virtual Earth so I could get a better idea of the technology and compare it with what I knew about Google Maps. It was a very nicely done demo, and also included integration with other Live technologies, like messaging. It seemed like a very straightforward JavaScript library with a pile of useful features. Pulling together a quick POC for either platform for a proper comparison should be a snap.

Workflow Tip

9 August 2007

Mick Badran reckons that you should always be developing workflows based on WF that are state machine based instead of sequential workflows. Since I’ve never done a state machine workflow, I’ll need to investigate them more and find out what the major advantages are; I think the main thing would be flexibility & extensibility of the workflow. Google is indicating I might want to start here and here.

Non-SharePoint Stuff

9 August 2007

TechEd has been a good opportunity to pop my head up out of the Sea of SharePoint and check out some of the interesting new/other technologies coming out from Microsoft. Since the conference this year has been not as SharePoint centric now that 2007 is an established product, there have been plenty of opportunities to have a look at all kinds of stuff. Here’s a quick overview of things I wouldn’t mind checking out in my free (ha! yeah, right) time.

  • LINQ
    Extends the .NET framework for easy data query & transformation operations in a functional programming type approach. LINQ will be integrated into Visual Studio 2008, but you can use it now. I also found this very nifty LINQ to SharePoint provider on CodePlex that I will need to check out (could it be the end of having to manually compose CAML? Oh I hope so)!
  • Dynamic Data Controls
    This ASP.NET library provides a set of web controls that bind to data sources and cut out a lot of the typical, repetitive drudgery of setting up a rich, data-driven web application with data listings, views, insert, update & delete operations & UI. And, even better, combine them with LINQ for some really simple, clean, maintainable code. We got a demo of the library that will be ready in the August ASP.NET futures download.
    The Windows Presentation Foundation is a framework for developing rich applications using a declarative XML format (XAML) to control UI, and .NET managed code to handle the business logic/functionality. Having seen the demos, I think XAML is what XHTML should be! Well formed and with tons of functionality (like, *gasp* columns!). Better still, WPF applications will be able to work as web applications as well as Windows client applications.

Veerrry interesting… Is it especially geeky of me to contemplate chucking a sickie just so I can play around with new development technologies?

OK, that may be a mild exaggeration, but the best thing I learned today was in a session co-presented by SharePoint genius, and my co-worker, Ishai Sagi.

If you don’t know how SharePoint Features work, take a quick look at the SDK as it can explain it far better than I can. Essentially what feature stapling allows you to do is piggyback features into a specific existing site definition without actually altering that site definition. Since you can implement just about any type of SharePoint functionality as a feature, including creating lists, content types, content, changing site settings, adding UI elements, and so on, that means you can easily customise out of the box site definitions.

SHEESH! I wish I had payed more attention to this six months ago– it would have saved me so many headaches.

I did a quick search and found this very thorough blog post by Chris Johnson from November last year that covers how to do it. A big thank you to Ishai and Milan Gross for introducing this concept to me.