I was in a SharePoint governance meeting at one of my customer sites yesterday and the group is thinking of enforcing some rules as far as SharePoint solution packages go. I kept saying during the meeting “Inspect the manifest file so that you can view what files are going to be installed on the server and where they are going to get installed”. One of the network engineers asked “How do you read a manifest file given a WSP?” This is probably common knowledge to people who are SharePoint veterans. But if you didn’t know how it’s done, here’s how:
- Rename the wsp file to a .cab file
- Open up the .cab file (used to be wsp) in WinZIP or something that can open a CAB file.
- You can either: a) extract all files in the cab file and open up the extracted manifest.xml; or b) look for manifest.xml in WinZIP and just extract that one single file.
- Open up manifest.xml in notepad, Internet Explorer, or your preferred XML file viewer.
That’s it!
Several of my upcoming posts will be on how to create solution packages. Stay tuned!
In the world of managed-code, the garbage-collector typically clears objects in memory automatically for you. Remember malloc() and free() in C++? In managed code, you just typically write “variable = new Object()” and the CLR will allocate the memory for you. In unmanaged world like C++, you had to allocated memory and then deallocate memory after use.
Most objects in ASP.NET Framework are allocated/deallocated in memory automatically. However, there are objects that inherit from the IDisposable. You have to explicitly dispose objects that implement the IDisposable interface or you will run the risk of memory leaks. Some examples of ASP.NET objects that implement IDisposable include Connection, Command, Adapater, and Reader objects (in the System.Data namespace). You can perform any of the following to dispose these objects properly:
SQLConnection connection = new SQLConnection(connectionString);
//use the connection object here
connection.Dispose();
Or, you can using the using statement:
using(SQLConnection connection = new SQLConnection(connectionString))
{
//use connection object here
} // don't have to call Dispose(); the using statement will dispose connection correctly
When working with SharePoint API (SharePoint .NET libraries and not the SharePoint Web services), it is important to know when and when not to dispose SharePoint objects. If you do not dispose objects in SharePoint, your server will run the risk of memory leaks which can lead to performance issues. If you dispose objects that you’re not supposed to call Dispose() on, you might inadvertently kill the SharePoint application! For example, the following code will definitely kill the SharePoint Web application:
SPContext.Current.Web.Dispose(); // expect calls to your help-desk with this line in your code!
If you are the custodian of the SharePoint farm, you might want to use the SP Dispose Checker Tool to ensure that the custom .NET assemblies being installed on your farm will not cause memory leaks.
For complete guidance on when and how to dispose SharePoint objects, you can read the SP Dispose Team blog.