Wednesday, April 30, 2014

PWA Eventing Service. Exception : System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: The system cannot find the file specified.

SCENARIO:
When a custom event handler is configured on PWA server the eventing service fails and timesheet events go into error state.
I developed Server-side event handlers for Project Server Timesheet Approval Cycle to send emails to timesheet writer and approvers. This included an assembly that calls PSI web services to interact with PWA that is registered in GAC and basicHttpBinding timeout changes to cater timout issues occuring while reading web service response.

The solution  I provided was successfully tested and verified on UAT environment and deployed to Production server and here starts the issue...

ISSUE:
    After registering the Event handlers to PWA the following error starts prompting. All the timesheets started giving error  and queued.   When cancelled from the queue the timesheet showed submitted state because they update the Published DB but didnot reflect in Reporting DB.
1.   “Couldn't validate configuration on eventing service: Exception: System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: The system cannot find the file specified.  
2.   “Standard Information:PSI Entry Point:   Project User: DOMAIN\User  Correlation Id: 1dcd87ae-9345-4733-b950-f8443ebb3fcb  PWA Site URL: http://site/PWA  SSP Name: Project Server PWA_ServiceApp  PSError: NoError (0) Queue unable to interact with SQL. Queue type (Project Queue, Timesheet Queue etc): TimesheetQ Exception: Microsoft.Office.Project.Server.BusinessLayer.Queue.QueueSqlException: CompleteGroup failed ---> System.Data.SqlClient.SqlException: Could not allocate space for object 'dbo.MSP_QUEUE_TIMESHEET_GROUP_ARCHIVE'.'CL_MSP_QUEUE_TIMESHEET_GROUP_ARCHIVE' in database 'ProjectServer_Published' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.   
3.   Error is: GeneralActionCanceledBecauseServerEventServiceProblem. Details: Attributes:  TimesheetReviewed  . Standard Information: PSI Entry Point:   Project User:DOMAIN\User  Correlation Id: 443945d0-741a-4eb2-99bf-4c2ba50e6365  PWA Site URL: http://site/PWA   SSP Name: Project Server PWA_ServiceApp  PSError: GeneralActionCanceledBecauseServerEventServiceProblem (22002)
After rolling back all the changes and unregistering the assembly from PWA   the IPC remote call error still prompted on every event call. Like if I delete , recall ,submit, approve or reject a timesheet
In the logs it shows in following order.
1.       Attempts to call IPC
2.       Throws error for number of retries attempted with following logs.
1.   ServerEventManager: Reconfiguring events 
2.   This occurs on every timesheet event i.e: submit, recall, delete, reviewed even after rolling back the deployment from Production server As shown in the log  below.  “Error during farm configuration change. Exception : System.Runtime.Remoting.RemotingException: Failed to connect to an IPC Port: The system cannot find the file specified. 

Resolution: 
 Most of the issues like thi are due to Firewall blocking IPC connections.
to resolve this issue you need to change the User account settings to minimum.


  • Go to Start   ---------->  Control Panel  ---------->  User Accounts  
  •  Change User Account Setting ----------------> Set the settings to never notify ----> Press OK

    • Restart the server if prompted.
    • Deploy the provided assembly and register the event handlers to PWA
    • Test It
    Issue Resolved :)

Monday, March 17, 2014

Reset SharePoint Config Cache

  The   path for the Configuration Cache under Windows Server 2008 is: C:\ProgramData\Microsoft\SharePoint\Config\<GUID>


Stop the Timer service. To do this, follow these steps:
1.      Click Start, point to Administrative Tools, and then click Services.
2.      Right-click SharePoint 2010 Timer, and then click Stop.
3.      Close the Services console.
4.      On the computer that is running Microsoft SharePoint Server 2010 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
5.      In Windows Explorer, locate and then double-click the following folder: C:\ProgramData\Microsoft\SharePoint\Config\GUID
Notes
1.      The GUID placeholder specifies the GUID folder. There may be more than one of these.
2.      The ProgramData folder may be hidden. To view the hidden folder, follow these steps:
·         On the Tools menu, click Folder Options.
·         Click the View tab.
·         In the Advanced settings list, click Show hidden files and folders under Hidden files and folders and then click OK.
3.      (You can also simply type this directly in the path if you do not want to show hidden files and folders.)
4.      Back up the Cache.ini file. (Make a copy of it. DO NOT DELETE THIS FILE, Only the XML files in the next step)
5.      Delete all the XML configuration files in the GUID folder (DO NOT DELETE THE FOLDER). Do this so that you can verify that the GUID folders content 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.
If Cache .ini is Missing
6.      Double-click the Cache.ini file.
7.      On the Edit menu, click Select All.
8.      On the Edit menu, click Delete.
9.      Type 1, and then click Save on the File menu. (Basically, when you are done, the only text in the config.ini file should be the number 1)
10.  On the File menu, click Exit.
11.  Start the Timer service. To do this, follow these steps:
·         Click Start, point to Administrative Tools, and then click Services.
·         Right-click SharePoint 2010 Timer, and then click Start.
·         Close the Services console.
12.  Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
13.  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.
14.  Check in the GUID folder to make sure that the XML files are repopulating. This may take a bit of time.


  If Cache.ini is missing under   “C:\ProgramData\Microsoft\SharePoint\Config\” or is deleted by mistake, perform the following Steps:
Now the mission is to get my Timer Job up and functioning. So I took the back-door approach to create GUID folder with Cache.ini file. Here are the steps I performed to get the config GUID of SharePoint.
1.      Stop the SharePoint 2010 Timer process.
1.      Open Windows Registry Editor
2.      Locate the ConfigDB key. Usually, it must be in this place if you are using SharePoint 2010.[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDB]
3.      You will see String Values entries for
4.      DSN: Connection string for your configuration database.
5.      Id: GUID of SharePoint configuration database. Copy this GUID.
6.      Goto C:\ProgramData\Microsoft\SharePoint\Config\ folder. (ProgramData folder is hidden, make sure change windows folder options to make it visible to you)
7.      Create a folder and name it as the GUID (that you just copied from Registry).
8.      Go into this folder, create a text file and name it as Cache.ini.
9.      Now edit this Cache.inikey in value 1 Save and close the file.
10.  Start the SharePoint 2010 Timer process.
11.  Do an IIS RESET
12.  Now check all your application pools are up and running. Otherwise, start them manually.  


Tuesday, November 5, 2013

Listing All Users in AD C# & ASP.Net

In a previous Post I described the code to get all the users in User Information List using Client Object Model.


In this post I will demonstrate listing all the AD users using C#. You need to add references to System.DirectoryServices and System.DirectoryServices.AccountManagement for this purpose.

Check the example below:

public class Example
{

   public List<ADUsers> ListAllADUsers()
        {
             List<ADUsers> users = new List<ADUsers>() ;


             using (var ctx= new PrincipalContext(ContextType.Domain, "your domain name"))
             {
                 using (var PSearcher= new PrincipalSearcher(new UserPrincipal(ctx)))
                 {
                     foreach (var account in PSearcher.FindAll())
                     {

                         string Name = Convert.ToString(account.DisplayName);
                         string SAMAccountName = Convert.ToString(account.SamAccountName);
                         string EmailAddress = Convert.ToString(account.UserPrincipalName);
                         users.Add(new ADUsers() { Name = Name, SAMAccountName=                                                                                      SAMAccountName, Email = EmailAddress });
                     }
                 }
             }
            return users;
        }
}
 public class ADUsers
    {
      
        public string Name { get; set; }        
        public string SAMAccountName { get; set; } 
        public string Email { get; set; }

    }

The method ListAllADUsers() returns the list of all the users in AD with Full Name, Domain Name and Email Address for each user.

Tuesday, October 29, 2013

Redirect to Another Page On Clicking OK in JavaScript Alertbox

Page Redirection after client script does not show the popup or alert box added to the code using ClientScript.RegisterStartupScript 

Example:

this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Operation Completed')", true);

 Response.Redirect("~/default.aspx"); 


In this code you will not get the alertbox and will be simply redirected to default.aspx page.

Modify the code like below

this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Operation Completed.');window.location='default.aspx';", true);  

This will show the alertbox and upon clicking OK you will be redirected to default.aspx page                  

Thursday, October 24, 2013

SharePoint Storage Metrics


Problem

Are you having a quota limit exceeded problem and you want to know which site or list/library is consuming all the storage. Increasing the quota does not help? 

Resolution:

Storage Metrics

You can trace the sites that are using maximum storage on the server.
Storage Metrics provide a summarized report of how storage for the site collection is being used across Site Collections and Sites. This helps administrators and owners to quickly identify content that can be archived or removed in order to remain within their allocated quotas.
To begin using Storage Metrics select Site Actions, and then click Site Settings.
From Site Settings select Storage Metrics under Site Collection Administration or simply enter the following URL
http://siteColl/_layouts/storman.aspx 
 It will show complete report of the site usage.
 You can drill-down to building block level by clicking the title of the items in the report.

Storage Metrics shows wrong size of the list item or Document

The storage metrics shows a huge size of the documents ( that is not the actual size) due to its previous versions that are stored in its Content Database. 
As an example http://siteColl//Documents/abc.pptx this file has an actual size of 55.6 MB  and has 300 versions available so it takes a total quota size of 300 x 55.6 MB data. 
If this is the issue with a single document library or a list or lets say a few of them you can simply limit the maximum versions according to need (I set it to 5) for that library. But we actually need a permanent solution for the issue as there are a lot of documents available. 
A hotfix from Microsoft is available on  http://support.microsoft.com/kb/2687339  Apply this hotfix on your server. Or you can write custom code in Powershell or Server Object model to update the maximum version of the libraries or lists to desired numbers and updating all the list items.


Limiting the versions of document libraries and list while enabling versioning is a huge plus.




Wednesday, October 23, 2013

IE Crash When Adding a new List Item in to a List in Datasheet View

I came across an issue from one of the clients regarding Internet Explorer crash when user tried to a new list item in to a custom list. This list had many fields of around all field types including four to five Person or Group fields.

Reported Problem:
1. Can attach documents to existing rows, but cannot add a new row for a new item without Internet Explorer freezing. 
a. Click Debug and receive an “Unhandled win32 exception in iexplore.exe (10940)” error message
How it happens:
1. Either click New to add a new row in the Datasheet view, or go to the bottom of the datasheet and start populating fields in a blank row.
After populating all fields, and tabbing, the progress (activity) indicator above the clock will change from blank to green bars going back and forth. THEN, Internet explorer returns an error message, “Unhandled win32 exception in iexplore.exe (10940)”.

Resolution: 

SharePoint 2010 List Datasheet View has a known bug of this type, Microsoft  provides a hotfix (Click for Official Link to the Hotfix) named " Office 2010 hotfix package (Stslist-x-none.msp): October 30, 2012" for this issue. Download and update your server for the issue if it occurs for all lists. 

In my case, a similar list worked fine created from its template. The problem was just with the list. The last solution was to create a backup for the list and check all the field that possibly could cause the Problem 

Delete all the fields with Calculated field type and Person and Group field type  one by one and try testing the list again,I found out that a Person or Group field was responsible for the issue, I recreated it, stopped related workflow, cleared browser Cache but it was none of my use.

At last I found out that the field allowed multiple user selection, disallowing multiple selection (not needed in my case) resolved the issue.

I hope this helps :)





Tuesday, October 22, 2013

Creating a lookup field in SharePoint List Programmatically


        private void CreateList(SPWeb web)
        {
            SPListCollection lists = web.Lists;
            SPList list = lists.TryGetList("Child List");
            if (list == null)
            {
                lists.Add("Child List", "Example child list "  , SPListTemplateType.GenericList);
                list = web.Lists["Child List"];
                list.OnQuickLaunch = true;

          #region CreatingListFields
            if (list != null)
            {
                SPFieldText txtField = null;

                // Rename Title Field
                txtField = (SPFieldText)list.Fields["Title"];
                if (txtField != null)
                {
                    txtField.Title = "Text Field";
                    txtField.Update();
                }

               // Creating a lookup field
               SPList targetList= web.Lists.TryGetList("Parent List");
               if (targetList != null)
               {
                   list.Fields.AddLookup("Child Lookup Field Name", targetList.ID, false);
                   SPFieldLookup lookup = (SPFieldLookup)list.Fields["Child Lookup Field Name"];
                   lookup.LookupField = targetList.Fields["ParentListFieldName"].InternalName;
                   lookup.AllowMultipleValues = false;
                   lookup.Update();
               }             

                list.Update();
            #endregion

                // Add a default View to the List
        
            #region DefaultView 
            SPView view = list.DefaultView;
            view.RowLimit = 30;
            view.Title = "All Items";
            view.Update();
            list.Update();
            #endregion
        }
}