MSBee – The new buzz in town
May 17th, 2006 // 12:05 pm @ Amar
I have been playing around with the MSBee project. I was trying to figure out, how to build my .NET 1.1 based SharePoint webparts projects using Visual Studio 2005, while keeping the project unchanged so that other VS 2003 users can work on it without any problems. That was when I came across MSBee. The Beta 2 had been released somedays ago and it is a nice addition. I wanted to start using VS 2005 on a regular basis and not only for R&D purposes but existing projects required me to build .NET 1.1 code. So cannot make the transition, and ended up installing both VS2003 and VS2005 previously. This time, I am determined not to install VS2003 on my main dev box and somehow get VS2005 to do all my work. For those adamant people like myself, check out the MSBuild Extras Project.
Category : dotNet
Renaming Title field in SharePoint Lists from Schema.XML
May 16th, 2006 // 5:05 pm @ Amar
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 @ Amar
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 @ Amar
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 @ Amar
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 @ Amar
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