EPiServer Export, Import or Mirror Troubles?
I have been working a lot with migration and mirroring lately using EPiServer’s functions for export and import of data.
My EPiServer Wish list
- Show call stack when exceptions halt export or import jobs
- Show PageID and Property related to errors and warnings during import and export
This area of the product is still one of EPiServer weaker areas mainly because the error massages when something goes wrong does not contain enough information.
I want to share the last issue I run into today and also show how I did to find out what was wrong. We could not export and only got this lovely message:
The following errors have occurred: Exception: Object reference not set to an instance of an object.
As you can see not much to go on here…
Strategy to resolve issues with EPiServer Export
2) We must make sure it halts on thrown exceptions even if it outside our code. Open your options dialog and uncheck”Enable Just My Code”.
With default settings the debugger will only break on uncaught exceptions.
3) We need the debugger to break when an exceptions are thrown regardless of they are handled by a try-catch statement.
This can be changed in your Exceptions dialog (Ctrl+Shift+E). You can either set it to catch all managed exceptions as I have in the screen shot or if you know what exception you are looking for you can halt on that one alone.
We are now ready to start the export again to trigger the error. If everything is correctly configured it will break on the exception and show you a call stack.
Analyzing the call stack and Disassembling EPiServer
Use Lutz Roeder’s .NET Reflector and click File>Open to load all assemblies in your web applications bin-folder. Search for the class or method and Disassemble the two methods and get more clues.
In this case it is probable that calling split on categoriesAsIds when categoriesAsIds is null is the culprit.
Looking at the calling method we can see that it is calling TransformCategoryForExport for PageDefinitions (a PageDefinition is another name for a property on a page type) if it as a Category. It does so to convert the Default Value for a Category property into a string with names instead of integer ids.
Conclusion and workaround
It is not possible to export a page type if you add a property of type Category selection (in EPiServer CMS 5 RC1 SP1 5.1.422.122). The reason is that default value is null and an easy workaround is to set the default value to “1” for each added Category property. The value “1” is the root category.