Welcome to MSDN Blogs Sign in | Join | Help

Eric Kraus' SharePoint/.NET Blog

What the field says about MOSS.

News

  • Subscribe to this blog


    Eric Kraus on Live Messenger




      Disclaimer
      These postings are provided "AS IS" with no warranties and confer no rights. In addition, these postings are my own and do not represent the views of Microsoft.
    Cannot remove file "". Error Code 158

    While developing a custom feature receiver, I was attempting to delete a masterpage file from the MasterPage Gallery when I received an SPException with the message:  "Cannot remove file "<filename>".  Error Code 158

    ErrorCode158_Error

    Since I found no help on the web, I thought I would share this simple solution. 

    I did the usual routine of checking if the file was checked out or missing, or if the user didn't have permissions.  But then I tested whether or not I could delete it in the UI, and I received this message: "You cannot delete the master page.  It is currently set as the default master page for the web site."

    ErrorCode158_ErrorDelete

    So now it made sense, all you need to do is switch the MasterPage in the Site Settings.

    ErrorCode158_SiteSettings

    ErrorCode158_SetMasterPage

    Done!

    Posted: Tuesday, August 05, 2008 10:24 AM by ekraus
    Anonymous comments are disabled
    Page view tracker