Why we are using warm-up scripts

SharePoint is built upon the Microsoft .NET Framework and ASP.NET, specially the 2.0 releases of those technologies. ASP.NET is architected so that its pages are not compiled until the first time a server request .As you know when an IIS worker process has coming up for the first time , It makes lots of jobs in the background. The big portion of this time used by compiling assemblies, and reading configurations  . For a standard ASP.Net application it takes very small time but for a SharePoint Application we have tons of assemblies and configurations and more than one WCF services which is need to be activated . So it will usually takes more time over 1 minutes. The warm up duration also depends on your configuration , hardware and assembly counts and changes for every system.

The issue happens when application pool recycle, iisreset or a worker process crashes.  And for SharePoint sites every application pool has a configuration that force the recycle itself . You can check from IIS -> Application Pools -> (For example Select “SharePoint Central Administration v4”) and right click   Select Recycling option And you can see the recycle time.

We have also an Idle Time Out property defined in Application Pool settings that make free worker processes resources which are in idle state for defined time period . Configure Idle Time-out Settings for an Application Pool (IIS 7) http://technet.microsoft.com/en-us/library/cc771956(v=WS.10).aspx

However even it is disabled by setting “Idle Time Out” value to 0 still IIS requires and also suggested way that recycle application pools daily manner. The default IIS behavior of naturally cycling an app pool somewhere between 1am and 3am or off hours if there is such a thing is healthy to clean out the memory space in IIS. Also same consideration is valid for SharePoint Timer service , there is a Timer job in SharePoint for responsible to restart timer service in daily manner. It is a good and suggested thing http://blogs.msdn.com/b/besidethepoint/archive/2012/01/10/the-timer-recycle-job-job-timer-recycle.aspx

But sometime in the midnight a recycle occurs and assume that no one send a request a server until morning and when a user open his browser and try to connect SharePoint site He/She should wait more, because the worker process is only getting up until the first time a server get the request. Warm up scripts send a requests to your server for a scheduled time  that forces IIS to worker process up and running .when a user’s request a page through a browser, preventing your users from seeing a delay when making that first request. That’s pretty much all they do, and the only purpose most of them serve is to “warm up” your server by having precompile your site’s ASP.NET pages ahead of an actual user request. You can use warm up scripts .

For the warm up scripts which is described in fallowing article http://blogs.technet.com/b/rgullick/archive/2011/12/02/minimalist-sharepoint-warmup-script.aspx have very common usage on this kind of issues.

 

Advertisement

If you are getting “Method not found” (MissingMethodException) error in SharePoint 2010

“Method not found” error i admit its my favorite 🙂 If you get this MissingMethodException from any of your build in SharePoint assembly for example below “Microsoft.SharePoint.Library” the first place you may check the dlls versions. This error usually caused by some version mismatch between your related dll version and SharePoint version.

You can see the error samples below:
Exception information:
Exception type: MissingMethodException
Exception message: Method not found: ‘Void Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(System.String, System.String, Boolean, Boolean, Boolean, Boolean, Boolean, Int32 ByRef, System.String ByRef, System.Guid, Boolean, System.String, System.Object ByRef, System.Object ByRef, System.Object ByRef, Boolean, Boolean, Boolean, Boolean, System.String, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter, Microsoft.SharePoint.Library.ISP2DSafeArrayWriter)’.

Stack trace:    at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)
   at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)
   at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)
   at Microsoft.SharePoint.SPListItem.Update()
   at Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment)
   at Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

So what could cause this issue
1) Unsuccessful upgrade or a corrupted installation.
2) Custom solutions that referenced old dlls
3) Deploying SharePoint solutions which is accidentally overwriting old dll on new version.
4) Unnecessery GAC registrations for build-in SharePoint DLLs

In this scenario we don’t have any custom solutions . So we may facing with first issue above, so how to fix the issue:
1) Define that which dll in use and this exception has thrown up. Answer for this scenario is “Microsoft.SharePoint.Library.dll”
2) Check the all dll versions in your system and compare with your SharePoint Build Number from Central Administration- > Migration and Upgrade -> Check product installation and patch status.
Here you can find powershell commands for searching versions of specific file in your system.
https://blog.bugrapostaci.com/2011/12/26/powershell-find-files-with-versions/
3) Correct dll version if you have orginal version of this old dll.
or
4) Upgrade your SharePoint for  newer version of Cumulative Update than your build will solve this issue.

By the way if you are thinking the problem caused by a Custom Solution you may check fallowing article:
https://blog.bugrapostaci.com/2011/12/28/getting-null-reference-exception-when-try-to-open-list-settings-listedit-aspx-for-sharepoint-2010/

Have a nice day.

 

Getting null reference exception when try to open list settings (Listedit.aspx) for Sharepoint 2010

This is a typical  error scenario that you have if you move or copy some sharepoint core dll’s which is referenced fr0m another folder.There is common mistake when developing custom applications that moving and copying sharepoint core dll’s to where is not in original folder (for example coping Microsoft.Sharepoint.dll to BIN folder of web application)  or unnecesserly register in GAC (for example registering Microsoft.Sharepoint.ApplicationPages.dll to GAC).

Why is this dangerous ? i can simply say when you upgrade or install any patch on sharepoint , the copied dlls form original location  can not be upgraded  by default .So this cause a huge anomality in your system. DLL version integrity is very important issue for every Microsoft product. So be careful for this operations , after all if you still need to copy or move operation, that upgrading copied dlls is your responsibility.

So lets keep going with our error :

when you click the one of list’s list settings (listedit.aspx) you can probably getting fallowing error in application event logs:

Exception information:
Exception type: NullReferenceException
Exception message: Object reference not set to an instance of an object.

Stack trace:    at Microsoft.SharePoint.ApplicationPages.ListEditPage.SetSectionLinks()
at Microsoft.SharePoint.ApplicationPages.ListEditPage.OnLoad(EventArgs e)
at ASP._layouts_listedit_aspx.OnLoad(EventArgs e) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\listedit.aspx:line 25
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

And if you enable custom errors from  in your web.config which is in Layouts folder.You can see the error in browser:

NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.ApplicationPages.ListEditPage.SetSectionLinks() +426
Microsoft.SharePoint.ApplicationPages.ListEditPage.OnLoad(EventArgs e) +896
ASP._layouts_listedit_aspx.OnLoad(EventArgs e) +290
System.Web.UI.Control.LoadRecursive() +65
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2427

For resolving this issue you should find the related copied assembly files which according this scenario is Microsoft.Sharepoint.ApplicationPages.dll in use for unfamiliar locations.

the orginal location for this dll is  Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\BIN

1) First Check the GAC this dll should not be added to GAC if it is upgrade latest correct version or delete the dll.
2) Check other possible existance may it be used in BIN folders of web applications. For getting all list of any dll location you can use this script:
https://blog.bugrapostaci.com/2011/12/26/powershell-find-files-with-versions/ this powershell command gives you a list that defined dll locations and versions.

For best practise if you need any reference to Sharepoint DLL’s use and reference them in original locations .if not you always remember to upgrade latest versions where it have been that is your resposibility.

See you next time.