Skip to main content

A look under the hood, using Reflector to explore Microsoft.SharePoint.dll

 

We've all used Reflector to open up a .NET assembly and look at the code. But did you ever think of doing this to the core SharePoint assemblies? I had never thought of it until last week at Sleepless in Dallas, Nadeem Mitha of Infusion suggested it. It is quite instructive, and reveals a couple very important nuances that if you don't understand can make your code very slow.  For example, looking at the SPList.Items property you can see that this property simply calls the GetItems() method to retrieve all items for that list. So here is the kicker, any time you call the Items property it is retrieving all the items in the SharePoint list, even if you just call the Items[0] , SharePoint retrieves all the items in a list and then peels off the first one and gives it to you, very inefficient.

image

Other classes to look at are  GetItemByUniqueId(Guid uniqueId). You can see that behind the scenes, Microsoft is creating a CAML query and retrieving items. Why Microsoft insists on throwing an exception when no results are found, is beyond me. A simple null would have sufficed, thank you very much!

image

 

I always thought the assemblies would have been obfuscated, but surprisingly, and to our benefit, they aren't. Hope this gives you some idea, but I think this is a great tip! It takes a lot of the mystery out of SharePoint, and also shows what the heck Microsoft was thinking.

Comments

Catto said…
Hey Now Joseph,
Lutz sure produced a great tool. Nice Post.
Thx 4 the info,
Catto

Popular posts from this blog

How to Create and Run Tableau Bridge on Linux Containers

Tableau Bridge is now availble on Linux Containers. Yay! Now what does this mean and how do I build and run Linux Containers? We will discuss the advantages of running Bridge on Linux Containers the steps to build them, and finally, we will provide some automation script ideas for monitoring and scaling Linux Bridge agents. Tableau Bridge Today Until recently, Tableau Bridge was only available as a Windows application running on a Windows VM. It supported only one bridge agent per Virtual or Physical Machine. Advantages of Bridge in Containers Better Hardware Utilization: Linux containers are more efficient than Windows VMs, requiring only about 1/50th of the disk space. Ability to Spin Up Multiple Bridge Agents: With Linux Containers, it becomes easier to spin up multiple bridge agents on a single machine, improving scalability and resource utilization. Infrastructure Automation: Linux Containers enable easier automation of provisioning bridge agents and upgrading Tableau Bridge, the...

RAM Disks do not speed up Visual Studio

  The limiting factor for Visual Studio is disk IO. I got a tip to speed up Visual Studio from Channel 9 by creating a RAM disk which sounded like a great idea. However, when I ran a thorough set of tests, I found that the performance difference between the Ram disk and the hard disk were not appreciably different. This was a big surprise since RAM is 240,000 times faster than disk (see my previous blog post). But the reason is because Visual Studio and Vista do a lot of caching. So compile times for the same project in RAM disk and on hard disk were pretty similar. I also tested the time it took to search the entire solution for a word, and times to open a solution. There was no discernable difference!   If you still want to try it out and create your own RAM disk, you can download a simple RAMDISK.EXE utility to create a RAM disk in just a few minutes. What is a RAM Disk ?   Ramdisk is a virtual drive created in RAM.   Performance Analysis Creating f...

SpreadsheetGear vs. SyncFusion vs. ComponentOne

I conducted a three month analysis comparing three top spreadsheet controls for .NET application developers: SpreadsheetGear , SyncFusion Spreadsheet , and ComponentOne Spread.NET . The definite winner was SpreadsheetGear, with ComponentOne Spread.net in second. SpreadsheetGear provides the most Excel-like experience, is the most performant, and provides the most responsive and capable product support. I build a reporting engine for my company and SpreadsheetGear made it awesome. Our customers have been very pleased. I wanted to share my extensive analysis with any other developers out there trying to find the right spreadsheet control for their .NET application.   Comparison Spreadsheet gear grid goes to 1 million! Wow. (SyncFusion goes to 500 by default, ComponentOne goes to 60k) SpreadsheetGear is an older control which has been around for a while. It is built by the same guys who built Formula1, so they have been doing spreadsheets for many years. Sp...