Monday 14 April 2008

Accelerate your InfoPath managed code development

Like most developers, I'm always looking for ways to speed up the code/test/get feedback cycle. There are many ways to do this in SharePoint development, and I guess a typical example would be to do application pool recycles rather than full IISResets. Along similar lines, anyone who has spent time doing Visual Studio/WF workflow development in SharePoint would hopefully have discovered the DEPLOY QUICK parameter on the build script MS supply - this will simply GAC the updated workflow assembly rather than perform a full deployment of the workflow Solution/Feature. This alone will probably shave many hours off a significant workflow project.

When working with InfoPath forms which have managed code, we need to deploy as an administrator-approved form rather than publish directly to a list or content type. The process is:

  • publish the form to the filesystem
  • upload the form via 'Manage form templates' in Central Admin

In the background, the last step actually wraps the form .xsn and associated assembly in a Solution and Feature, and deploys throughout your farm. Understandably this is S-L-O-W for development, so I started looking at ways to speed this up. Interestingly the assembly doesn't get deployed to the GAC or web application bin directory, but resides solely in the folder for the Feature (click image to enlarge):



Nevertheless, instead of publishing the form we can do the following:

  • compile VSTA/VSTO project
  • copy .dll (and .pdb if we're in debug mode) over the ones in the Feature folder
  • recycle app pool

This will then load the updated code. Note because we've only deployed the updated code to the local machine, only form sessions on the local machine will be affected (I'm assuming you're not using a load-balanced URL in dev) - this has a nice side-effect of isolating your changes from other developers in the farm until you're ready to release them.

I'm interested to know how InfoPath accomplishes the trick of loading assemblies from this location at run-time -there are no custom 'probing' entries in my web.config (instructions to tell .Net to probe custom locations for assemblies) so I'm assuming it's done via reflection.

If you have your own tips for speeding up SharePoint development which aren't commonly-known, I'd be interested to hear...

4 comments:

Anonymous said...

If your workflow includes a DelayActivity, DEPLOY QUICK won't work by itself. The SharePoint Timer Service must be restarted in order to have its cache that holds the old copy of the DLL refreshed. Been there. Been a victim of that. :-(

Chris O'Brien said...

Interesting gotcha, thanks for the tip..

Chris.

Anonymous said...

Good for people to know.

Larry W. Virden said...

Good morning! I am working with a developer who was discussing this problem this morning. Some days when he uploads a form template, the template takes 3 minutes or so to go into central admin. This morning, the process took over 30 minutes.

We are using MOSS SP 2007, service pack 3 as the platform, and he is using InfoPath 2010, in InfoPath 2007 compatibility mode, as his development tool.

Does anyone have other ideas on how to speed up the process of uploading templates to central admin?