Skip to content
May 29, 2011 / kiranpatils

RootItem will be null when you do Publish Site


We’ve built one application which shows us the status of our publishing process. But sometime it was throwing “Object reference not set to an instance of an object” error. We checked the code. But in code there were so many lines which can cause this error. We decided to put individual exception blocks. But while doing this process we found the steps to reproduce it and it helped us to find what was NULL


Basically we were using RootItem

//Gets Root Item Name
string rootItemName = ((Sitecore.Publishing.PublishOptions[])(job.Options.Parameters[0]))[0].RootItem.Paths.Path;

And when we do “Publish Site” [Shortcut is F9] at that time RootItem was null.

So, to fix it we checked whether RootItem is null or not and it fixed our problem!

So, In short When you do “Publish Item” you will get RootItem object else in “Publish Site” case you won’t.

Happy Publishing! 🙂



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: