Skip Ribbon Commands
Skip to main content

Robin | zevenseas | SharePoint Blog

:

The zevenseas Community > Blogs > Robin | zevenseas | SharePoint Blog > Posts > SharePoint file encoding and uploading the CustomQuickAccess.xml
June 07
SharePoint file encoding and uploading the CustomQuickAccess.xml

This week I was playing around with the publishing console to add some quick access buttons.. as you might already know, the publishing console reads a xml file that is stored in the “_catalogs/masterpage/editing menu” folder called the “CustomQuickAccess”. And as you already may know, this folder get’s created and populated by the publishing feature so it’s pointless to overwrite this file by using feature to your deployment script by using a Module in your element file. And the only ‘proper’ way of populating this file in the folder is by using a FeatureReceiver that uploads the file to the folder. Up until this point there a some blogposts that cover this scenario.. but little to none (I couldn’t find it :) that cover the last part that is of vital importance.. being the encoding that is used for the file.

So let’s say you want something like this awesome looking console :

image

Then the .xml looks file a bit like this:

<Console>
  <references>
    <reference TagPrefix="zevenseas"
               assembly="zevenseas.SharePoint.PublishingControls, 
Version=1.0.0.0, Culture=neutral, PublicKeyToken=92517b51c027cdc9"
               namespace="zevenseas.SharePoint.PublishingControls" />
  </references>
  <structure>
    <ConsoleNode Sequence="1"
                 ConfigMenu="Add"
                 HideStates="PageHasCustomizableZonesFalse|PageHasFieldControlsFalse"
                 Action="zevenseas:ViewAllPagesAction"
                 ID="zevenseasViewAllPagesAction" />
  </structure>
</Console> 

I did this using SPD and copying the .dll into the GAC and everything was working like a charm.. Next step was to make it deployable using a FeatureReceiver by uploading the .xml file.. not a big deal.. had done that many times.. so walk in the park right? WRONG!

So what went wrong you might wonder.. well.. every time I upload the file using a console application (for testing out my soon-to-be feature receiver) I encountered the following problem:

image

Console Configuration File Error: XML Exception: The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.

First I thought it may had something to do with the method of uploading the file SPFile.SaveBinary() vs SPFiles.Add() .. but that wasn’t it. Then I looked back at previous projects and I noticed that in one project in particular I was doing the following :

ASCIIEncoding asciiEncoder = new ASCIIEncoding();
file.SaveBinary(asciiEncoder.GetBytes(fileInStream));
file.Update(); 

So next step was to reuse that piece of code and check if that would do the trick.. and as you may have guessed.. that indeed do the trick! :) I checked the Save setting of my file in the project and it was set to UTF.. I changed that to ASCII and voila .. it worked!

Conclusion

Make sure that you upload files using the ASCII file encoding otherwise SharePoint has problems with loading the files..

Comments

Sander Schutten

Thanks! Helped me a lot.
System Account on 08/07/2010 00:58
 

 Statistics

 
Views: 2251
Comments: 1
Tags:
Published:1077 Days Ago