Programmatically generated list from CheckoutStepsTemplate throws an exception

(This question was cross-posted on the MSDN forums here .)

I am working on a custom SharePoint / Commerce Server site and I have a custom function that is designed to do two things: expose some pages through modules and provide a list of checkout steps using the CheckoutStepsList template into the receiver function. For some reason, however, in some cases, creating a list throws an exception:

Invalid file name

The specified file name cannot be used. This may be the name of an existing file or directory, or you may not have access to the file.

When I try to navigate to the list, it takes me to the list settings page (there should be a default view) and there are 0 items in the list. So it looks like it provided the list halfway, but crashed somewhere in the middle.

This problem is difficult to reproduce. If I activate the feature through the stsadm command on the command line, it always fails, but if I do it through the SharePoint interface, sometimes it fails and sometimes it doesn't. Crash via UI seems to happen more often if the pages exposed via modules don't exist yet, but I'm not sure yet.

Here's the offensive code:

SPListTemplateCollection listTemplateCollection = web.Site.GetCustomListTemplates(web);
SPListTemplate checkoutStepsTemplate = listTemplateCollection["CheckoutStepsTemplate"];
Guid listID = web.Lists.Add(listName, String.Empty, checkoutStepsTemplate); // the exception is thrown on this line

      

Any idea what's going on here? I'll continue debugging this at my end and I would be happy to provide any information that might help diagnose the problem.

+1


a source to share


1 answer


I've never found a complete solution to this problem, but I've diagnosed enough to find an acceptable solution. It turns out the problem only occurred when initializing elements through modules in the same function, but when those modules are included in another function, everything works fine.



We decided to move on, so as far as I was able to find the root cause of the problem, but this is at least a good enough fix that won't cause us headaches in the future.

0


a source







All Articles