Tuesday, August 20, 2013

Why Dispose SharePoint Object ?

We usually don't take care much about disposing the objects explicitly in Asp.net application , as it is taken care by the Garbage Collector itself.As SharePoint itself is built on top of the .net Platform , then why it is always recommended to dispose the SharePoint Object !

In true sense most of the SharePoint Foundation objects, primarily the SPSite class and SPWeb class objects, are created as managed objects.
 However, these objects use unmanaged code and memory to perform the majority of their work. The managed part of the object is much smaller than the unmanaged part.
Because the smaller managed part does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner.
The object's use of a large amount of unmanaged memory can cause the unusual behaviors specified below :

  • High memory use for Internet Information Services (IIS) worker processes
  • Poor system and application performance 
  • Frequent recycles of the SharePoint Foundation application pool, especially during peak usage
  • Application crashes that appear as heap corruption in the debugger
Calling applications that work with IDisposable objects in SharePoint Foundation must dispose the objects when the applications finish using them. We should not rely on the garbage collector to release them from memory automatically. 

Thursday, January 17, 2013

Compare Two SharePoint DateTime Control Javascript


 Event Starts :  <SharePoint:DateTimeControl ID="dtEventStarts" LocaleId="2057"   runat="server" />                            
                         
 Event Ends :   <SharePoint:DateTimeControl ID="dtEventEnds" LocaleId="2057"  runat="server" />
                                                        
 //Compare the start date and End Date of without recurrance patter
 function validatePlainStartDateAndEndDatePattern(source, args) 
{
            var chkEventRepeatsControl = document.getElementById('<%= chkEventRepeats.ClientID %>');         //get the check box value for testing event is recurrence or not
            if (!chkEventRepeatsControl.checked)
            {
                var eventStartDateString = document.getElementById('<%=dtEventStarts.Controls[0].ClientID%>').value;            
                var startdateDTA = eventStartDateString.split("/");
             
                var actStartDate = new Date(startdateDTA[2], startdateDTA[1], startdateDTA[0], (document.getElementById('<%=dtEventStarts.Controls[1].ClientID%>').value).replace(":", ""), document.getElementById('<%=dtEventStarts.Controls[2].ClientID%>').value);
                alert(actStartDate);

                var eventEndDateString = document.getElementById('<%=dtEventEnds.Controls[0].ClientID%>').value;
                var EndDateDTA = eventEndDateString.split("/");
                var actEndDate = new Date(EndDateDTA[2], EndDateDTA[1], EndDateDTA[0], (document.getElementById('<%=dtEventEnds.Controls[1].ClientID%>').value).replace(":", ""), document.getElementById('<%=dtEventEnds.Controls[2].ClientID%>').value);
           
                if (actStartDate.getTime() < actEndDate.getTime())
                {
                    args.IsValid = true;
                }
                else{
                    args.IsValid = false;
                }
            }

        }

Tuesday, October 25, 2011

Timer Job stuck at 0% progress


Resolution :Toresolve this issue, clear the file system cache on all servers in the serverfarm on which the Windows SharePoint Services Timer service is running. To dothis, follow these steps:
  
  1. Stop the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click Windows SharePoint Services Timer, and then click Stop.
    3. Close the Services console.
  1. On the computer that is running Microsoft Office SharePoint Server 2007 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
  2. In Windows Explorer, locate and then double-click the following folder:
Drive:\Documents andSettings\All Users\Application Data\Microsoft\SharePoint\Config\GUID
Notes
    • The Drive placeholder specifies the letter of the drive on which Windows is installed. By default, Windows is installed on drive C.
    • The GUID placeholder specifies the GUID folder.
    • The Application Data folder may be hidden. To view the hidden folder, follow these steps:
      1. On the Tools menu, click Folder Options.
      2. Click the View tab.
      3. In the Advanced settings list, click Show hidden files and folders under Hidden files and folders, and then click OK.
    • In Windows Server 2008, the configuration cache is in the following location:
Drive:\ProgramData\Microsoft\SharePoint\Config\GUID





  1. Back up the Cache.ini file.
  2. Delete all the XML configuration files in the GUID folder. Do this so that you can verify that the GUID folder is replaced by new XML configuration files when the cache is rebuilt.

    Note When you empty the configuration cache in the GUID folder, make sure that you do not delete the GUID folder and the Cache.ini file that is located in the GUID folder. 



  1. Double-click the Cache.ini file.
  2. On the Edit menu, click Select All.
  3. On the Edit menu, click Delete.
  4. Type 1, and then click Save on the File menu.
  5. On the File menu, click Exit.
  6. Start the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click Windows SharePoint Services Timer, and then click Start.
    3. Close the Services console.
Note The file systemcache is re-created after you perform this procedure. Make sure that youperform this procedure on all servers in the server farm.
  1. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.
  2. Click Start, point to Programs, point to Administrative Tools, and then click SharePoint 3.0 Central Administration.
  3. Click the Operations tab, and then click Timer job status under Global Configuration.
  4. In the list of timer jobs, verify that the status of the Config Refresh entry is succeeded.
  5. On the File menu, click Close..



Drives used for SQL databases are running out of free space.

Reason:   One or more of the following might be causing this:

1. Size on the drives are not sufficient .
2.The problems at the URL Expired-sessions-are-not-being-deleted
3. Perhaps the SQL error log is spamming and has filled up the entire C drive.

Resolution:
1. The resolution to the Expired-sessions-are-not-being-deleted will take care of it (partially).

2. Manage the Size of the SharePoint_Config Database :
The SharePoint Config database can grow to a large size and you need to make sure to maintain this (and all other SharePoint Databases).
Follow these steps to shrink the SharePoint databases:
[Make sure that you have enough disk space available before this procedure]

1.      Start SQL Server Management Studio and look at the Disk Usage Report




4.      Take a full backup of the SharePoint_Config database
5.      Take a transaction log backup of the SharePoint_Config database
6.      Now, configure the Config Database > Properties > Options > Recovery Mode = Simple
7.      Run DBCC ShrinkDatabase(SharePoint_Config, 10)
8.      Configure the database back to Full recovery mode Properties > Options > Recovery Mode = Full

3. Follow the Checklist specified below:
 Checklist to free space
1. Cycle the SQL errorlog to remove large error log files from the C drive - see script below
2. Clear out old mdf and ldf files from the \Data directory
3. Clear out old stack dumps and crash dumps from \LOG directory
4. Remove any redundant backup files
5. Delete old roaming user profiles from C:\documents and settings
6. Check any \temp directories and .tmp files for files to delete
7. Empty the Recycle Bin.
2>

Expired sessions are not being deleted from the ASP.NET Session State database

Reason:   One or more of the following might be causing this:

  • The SQL Server Agent service was stopped.
  • SQL Server Express is installed.
Note: We cannot run the SQL Server Agent service on an instance of SQL Server Express.

Resolution:   Start the SQL Server Agent service if it is stopped. Or else run the Timer Job State Service Delete Expired Sessions .
1.      Verify that the user account that is performing this procedure is a member of the Administrators group on the database server that is hosting the ASP.NET Session State database.
2.      In the Services snap-in, start the SQL Server Agent service.

To start the SQL Server Agent service
1.      On the Start menu, point to All Programs, point to Microsoft SQL Server 2008 R2, point to Configuration Tools, and then click SQL Server Configuration Manager.
2.      In SQL Server Configuration Manager, expand Services, and then click SQL Agent.
3.      In the results pane, right-click any instance, and then click Start.
A green arrow on the icon next to the SQL Server Agent and on the toolbar indicates that SQL Server Agent started successfully.
4.      ClickOK.





Or,
      1. On the Central Administration Web site, on the Quick Launch, click Monitoring.


 2. In the Timer Jobs section, click Review job definitions.
 3. Click State Service Delete Expired Sessions Job in the list of timer jobs.

4. Click Run Now.


Even after applying the above fixes the problem doesn’t get resolved go through the following steps:


1>    Check the Jobs under SQL Server Agent, and analyze the Job Activity Monitor report.

2>If the Session State Service job is not present ,create it using the following stored-procedure.


.
..
  

Verify that the Activity Feed Timer Job is enabled

Reason: Activity Feed is off by default in a User Profile Service Application. To turn on this feature, a member of the Farm Administrators group must configure the User Profile service Activity Feed timer job.

Resolution:

1. On the Central Administration Web site, on the Quick Launch, click Monitoring.




2. In the Timer Jobs section, click Review job definitions.
3. Click User Profile Service – Activity Feed Job in the list of timer jobs.

4. On the Edit Timer Job page, click Enable.

The server farm account should not be used for other services

Reason:  The Farm Account, which is used for the SharePoint 2010 Timer service and the Central Administration site, is highly privileged and should not be used for other services on any computers in the server farm. Services in the farm were found to use this account.

Resolution:   Change the account that is used for other services

1.      Verify that the user account that is performing this procedure is a member of the Farm Administrators SharePoint group.
2.      On the Central Administration home page, click Security, and then in the General Security section, click Configure service accounts.
3.      On the Service Accounts page, in the Credential Management section, in the upper drop-down list, click the service for which you want to update credentials.
4.      In the Select an account for this component list, click the domain account that you want to associate with this service.
If you want to register the account that you selected on the SharePoint Foundation 2010 farm, click Register Managed Account.







6.      Click OK.