Browsing Category SharePoint

Improving SharePoint performance

June 27th, 2006 // 3:06 pm @

This is a neat trick to improve the performance of your Sharepoint Box if you have custom webparts installed. Normally, the SharePoint indexer kicks in to index the pages, and when it does kick in, it causes an additional hit on the server. There may be cases, when you don’t want your custom webparts to connect to backend data systems and process the data when the indexer is accessing it. So what we have done, is to check if the current account calling the page, is the service account or not. If it is the service account, then just dont do anything. This way, we bypass the entire processing of each of our custom webparts, when the indexer is accessing them and hence decrease the overall load on the server.


On many systems, the indexer is set to kick in every 10 – 20 mins, so it is quite a bit of saving on extremely busy systems.

Category : SharePoint

Extracting dll’s out of the GAC

June 13th, 2006 // 7:06 pm @

I was recently asked how to reference the Microsoft.SharePoint and few of the other SharePoint dll’s in a project while developing on a non SharePoint machine. The solution is quite simple which we often seem to neglect.


This is applicable for any assembly which is installed in the GAC. If you use the Windows Explorer, you can see those assemblies in the Windows\Assembly\GAC folder, but cannot copy them out of there. To access the internal structure, use the command shell, by typing cmd in the Start->Run menu. Navigate to the GAC folder and you will see all installed dll’s as folders, which inturn will contain the corresponding folders for each version. Just copy the dll’s from there to some other location and you have successfully extracted the dll’s from the GAC.

Category : dotNet &SharePoint

Renaming Title field in SharePoint Lists from Schema.XML

May 16th, 2006 // 5:05 pm @

One of my colleagues asked me how to replace the title field in a SharePoint list with his own field and get the standard dropdown on that field. From my experience I have found that the title and id fields are very tightly intervoven with the SharePoint lists. It is easier to just change the display name of the Title field to whatever suits your needs.


If you open the standard schema.xml for any list, you will not find any definition for the title field. But still all lists contain that field. This definition comes from the onet.xml. It is not advisable to modify the onet.xml. However it is possible to modify the base field properties by simply overriding them in your schema.xml file. Just copy the definition, paste it in the fields section of your schema.xml, change the DisplayName to what you like, and add an attribute FromBaseType=”TRUE”. This will allow you to modify the way the base types work from your schema.xml.


Update: The title field actually displayed on the all items view is a calculated field called LinkTitle. This field is tied to the dropdown menu when you hover over the Title.

Category : SharePoint

Profile WebParts for performance and memory

May 15th, 2006 // 3:05 pm @

I recently wanted to profile some of my Webparts to identify possible memory usage and speed issues. So I started to look for some profiling tools which I can evaluate and maybe ask my company to purchase in the long run. I tried three tools. Compuware Devpartner Community Edition, AQTime and ANTS Profiler. First of all, let me clarify that this was no proper review. I did not have ages to sit and setup and determine which one performed best. All I wanted was which tool would get the job done quick and easy.


Devpartner Studio installed properly, but resulted in a blue screen crash on my PC when I tried to configure it to profile ASP.NET application. Also tried to run my application in debug mode but did not seem to work. Maybe I was doing something wrong or maybe it was not working properly due to that crash, but anyways I did not bother with it much and uninstalled it. Too bad, as I have always admired Compuware tools. Will maybe patch my PC and see if I can get it working again sometime in the future. Not sure when I will get time.


AQTime was a bit complex to use. I had to create a project and set it to profile and ASP.NET application. Tried to tell it to profile only my webpart assembly but it kept on profiling the entire ASP.NET application including the sharepoint dll’s and .net stuff. Tried tweaking for sometime, but no prevail. I guess I will have to read the manual sometime. But one thing I observed, was that it gives a lot of details. But unless I can tell it to profile all the classes and code in just my webpart, I don’t think I can make any sense out of the results.


The last and the hero of these tests was ANTS Profiler. One of the easiest tools I have used. Hardly took any time, and I configured it successfully to profile just my webpart. Fired off the sharepoint page in a browser, used it a bit and closed it down and voila, my results were ready. It works in two modes. Memory profiling and performance profiling. In performance mode, it showed all the classes in my assembly and the amount of time each took, the number of hits each received etc. Does not display a lot of details, but is perfect for my work as all I needed was to optimise the most hit code in my project. So my winner for today is ANTS Profiler. I have heard about Microsoft CLR Profiler, but have not used it. Will give it a try maybe later, but not I have some code optimisations to do :)


Incidently, ANTS Profiler was the smallest of the three, around 6 MB installation. The other two were around 40MB+. I personally like lightweight quick to use utilities which get the job done instead of heavy duty state of art stuff which would take ages to configure and run. Will like to spend more time using ANTS profiler within the trial period I have to evaluate it better and see how good it is?


With this post by no means I am suggesting a proper review and evaluation of the above tools. It is just my first looks with these tools having spent no more than 15 mins on each. If someone finds better results, do let me know as I am interested in finding a good memory and performance profiling tool.


Update: Compuware just offered me a free 14 day trial of their full version. Will try it out when I have a little bit of time and report my findings in a later post someday.

Category : dotNet &SharePoint

Warning: Do not delete the Navbars section from the onet.xml

May 11th, 2006 // 5:05 pm @

I recently ran across a problem with the Navbars section in Onet.xml. Let me explain what I did.


I had a template which did not use the quick launch bars, and had them removed from the aspx files. So I thought of cleaning up the onet.xml also. If I completely removed the Navbars section from onet.xml, I believe my site was crasing on creation. So, I removed some of the Navbar sections in the process to tidy up my site definition, and kept the site settings stuff. Everything was fine. The system worked nicely and I had all my customisation working perfectly. Then I hit a serious glitch.


Go into any list and modify its settings, go to general settings, and try to toggle the list setting of On Quick Launch Bar. It will always reset to No, as soon as you click Ok. Many people had complained on the boards that they were unable to set the list to appear on the quick launch bar, and the setting toggled to No everytime. It seems the Navbar section was the source.


I replaced the Navbars section in my site’s onet.xml. But the damage was done. Any new sites which I create from this template, were fine. But the sites which were already created using the old template ( one without the Navbar sections ), did not allow me to toggle the quick launch bar setting at all. Only option was to delete and re-create those sites.


Also, I did not spend much time on this, but the list type which were removed from the Navbar section on onet, were the ones, affected with this problem.


I know it is not advisable to modify onet.xml, but we do not live in a perfect world. It is a necessary evil. But do not remove those navbar sections, even if you are not using the quick launch bar in your pages. Go ahead and remove it from the aspx pages, but keep the onet stuff in.


I still can’t figure out what’s the link to that setting and the Navbar section of onet.xml. After all, when I toggle that value, it is just a small update to one of the boolean fields in the database. No idea how is onet linked to that functionality. Anyways, to conclude, do not remove the Navbars section from the onet.xml.

Category : SharePoint

Caching in SharePoint Web Parts

May 10th, 2006 // 3:05 pm @

I recently came across a very nice article on implementing caching in Web Parts. It describes the various options available for use and seems pretty nice. Have not read it completely yet, but thought of pointing you guys to it.


Check it out here.

Category : SharePoint

Error in removing Category Navigation WebPart from SharePoint Templates

May 8th, 2006 // 5:05 pm @

In general, it is quite easy to remove the Category Navigation WebPart SPSWC:CategoryNavigationWebPart from the SharePoint template. Just open the proper file, locate


<SPSWC:CategoryNavigationWebPart runat=”server” id=”HorizontalNavBar” DisplayStyle=”HorizontalOneLayer” />


and delete it. ( The attributes may differ ).


On certain very stubborn pages, it is just not possible to remove it. For example, take the txtlstvw.aspx page. If you remove the category navigation webpart from this page, you are presented with the following error:


[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.Portal.WebControls.TextListingViewerPage.OnInit(EventArgs ea)
System.Web.UI.Control.InitRecursive(Control namingContainer) +240
System.Web.UI.Page.ProcessRequestMain() +195


I was very curious about it, as most of the pages do not complain so strongly if we remove the webpart from the template. There was no obvious link in the template HTML which proves that some other control uses it, and I removed almost all existing default controls from the page, but the error still persisted. This led me to believe that the error was somewhere in the code-behind for this page.


So I opened Reflector and loaded the Microsoft.SharePoint.Portal.dll and navigated to TextListingViewerPage->OnInit. There I found this piece of code :


this.HorizontalNavBar.CurrentCategoryID = this.BreadCrumbTrail.CurrentID = guid1.ToString();


There was no error checking code before this which tried to check if either HorizontalNavBar or BreadCrumbTrail objects were null. Thus we were stuck here. There is absolutely no way to remove these two webparts from this page without crashing it.


But… There was a sly approach. If I can’t remove them, then I can definitely hide them. My goal was to knock off these and add a custom branding with custom navigation controls. Hence, all I did was surround the Category Navigation Webpart and the Breadcrumb Trail Webpart with


<div style=”display:none;”>…</div>


Do this same trick if you ever have such a problem. I do remember having this problem while branding some other page in SharePoint but cannot remember which one. This is evidently sloppy coding on the part of the coder who wrote that page, and I hope problems like these would be corrected in the future releases.

Category : SharePoint

Replacing SharePoint site creation page

April 13th, 2006 // 2:04 pm @

By default, when you want to create a new site or subsite, SharePoint presents the default site creation page. If you want to replace this page with your custom page, e.g if you want to add some more properties to the site, or do some checks before and after the site creation process, then the best way is to create your own page for doing this and instruct SharePoint to use your page instead. Here is how to do it:



  1. Create an .aspx page with your custom code for inputting user details, creating site and any additional activities.

  2. Place this file somewhere in the _layouts folder. This is not necessary, but just for uniformity you can keep the page in _layouts or _layouts/1033 or any other subfolder.

  3. Deploy the dll for that .aspx page in the appropriate bin directory for the web application.

  4. Go to SharePoint Site Settings. In the General Settings section, click on Change portal site properties and SharePoint site creation settings

  5. In the Location for Creating SharePoint Sites section, enter the link to your new custom site creation page.

That’s it. Whenever someone tries to create a new site, they will be redirected to your custom site creation page.

Category : SharePoint

How to brand a SharePoint Portal or Site for best results – Part 3

March 27th, 2006 // 6:03 am @

I have been a bit slow in posting on this series. Enjoying my holidays and relaxing most of the time :) Here is another installment of this series.


I will focus on one very important item of SharePoint branding. AlternateHeader.


You can brand pages from different templates, so as to give different look on sites / areas created from different templates. But what about the pages in /_layouts/1033 directory. These are common for all the templates, and as soon as the user hits any of these pages, they would hit the common pages.


Some of the pages in the _layouts directory have code to support the alternate header functionality.


In the page you will find a code block like this:


<%
string alternateHeader = SPControl.GetContextWeb(Context).AlternateHeader;
if (alternateHeader == null || alternateHeader == “”)
{
%>
<TR>


            …… code which is to be used if the alternate header is not defined


            …… goes here.
</TR>
<%
}
else
{
    Server.Execute(alternateHeader);
}
%>


This is a very nice way to brand these pages to have different look and feel when accessed from different template pages. The page to use as the alternate header, is definied in the onet.xml for the template concerned. Be careful and get this right before you create your site with that template, as it cannot be changed by modifying the template once the site is created. So before you start your sharepoint deployment it is essential that you get your alternate headers definited properly in the onet.xml.


Basically, have an alternate header for each template you have. This will let to assign an alternate header to pages from from templates in a 1:1 relationship.


E.g. Say you have several team sites with different branding, HR Site, Finance Site and Sales Site. You have created 3 templates for these 3 site types. Now your goals is to provide a seamless interface to the user whenever the user is presented any page from the _layouts/1033 directory, like viewlsts.aspx which is presented when the user tried to see the documents & lists in any site, or create.aspx when the user is trying to create a list.


Before you create your HR, Finance or Sales site, you will be creating 3 templates which would deifine the different branding of these 3 sites. It is essential that you plan ahead and assign different alternate headers in the onet.xml of these templates. In the &lt;Project&gt; element you can add the attribute AlternateHeader=”/_layouts/1033/HRAlternateHeader.aspx” in case of the HR Template.


Whenever a user opens a page in _layouts/1033 from a site created with the HR Template, he will see a page rendered with the header logic picked up from the HRAlternateHeader.aspx. This is provided the above code to include alternate header functionality is in that page. Not all pages from _layouts/1033 contain that code which is a bit of a pain. So for pages which do not have that code, you might want to edit them and add code support to use alternate headers if defined.


This will give you maximum flexibility while making good use of the excellent functionality provided by the AlternateHeader element. I will discuss creating and modifying templates in a later post.


For some providing more information on this alternate header functionality, see:


Category : SharePoint

File Not Found error on SharePoint pages

March 6th, 2006 // 3:03 pm @

This is another very common error I have found people getting completely stumped at. There is no error description, no debug information, nothing. Just a short sweet error saying “File Not Found”.


Don’t get stumped with this error. This is a very straighforward error which actually means that the page did not find one of the files it was asked to process. You must be wondering just what these files can me. So let me try to quickly rememeber on what kind of files I have faced this error.



  1. Any includes, usercontrols added to the template are not accessible. Check the link ( relative or absolute ). Most of the time the link is wrong.

  2. DLL’s missing. If you have added a webcontrol or a webpart in the template, then it might be that the page is unable to find the dll. You may have placed the dll in the bin directory in your website’s root but it might be that that particular page is in some other virtual directory and is referring to some other web.config and bin directory. e.g. For most pages from _layouts, the bin directory it referrs to is _layouts/bin and not _layouts/1033/bin. These kind of errors are very easy to overlook.

  3. If you code for using an alternate header, and the relative path to use that alternate header may be wrong and not loading the page.

I cannot think of any other reasons for this error to generally appear. Let me know if I forgot any. Most of the time it is either #1 or #2 which causes that error.

Category : SharePoint

Latest Posts

Testimonials

"Amar clearly has a thorough knowledge of Sharepoint, this knowledge, coupled with his professionalism and dedication made him a tremendous asset to the project. He was the key contributor to the later stages of the project delivery effort (the really difficult bit, long hours and hard work that puts huge demands on people), and I can state categorically that without his focussed dedication and hard work we would not have been able to meet the timescales imposed upon the project."

Tim Ellis , Sharepoint Project Manager , Royal Bank of Scotland

Subscribe Now