Wednesday, July 27, 2016

Application failure. hr=0x80040101: Failed to initialize virtual machine

Hi There,

Its 12:30 AM today in Pakistan and i have to do some work with my VMware. Tried to start it in normal and Administrator mode both but WOOOWWW..... ITS CRASHING....! I am getting a very weird error message that even Google did not provide any useful stuff to resolve this issue. Below are my environment details.

OS  :  Windows 8.1 Pro
VM :  VMWare Workstation 11.0.0 build-2305329

Error : Application failure. hr=0x80040101: Failed to initialize virtual machine

(This is not the actual screenshot of my error but the error was exactly same with the above Red text. I forgot to take screenshot of the error message before fixing it.)


I tried registering few DLLs as shared by someone in Chinese language here but it did not help me. So i decided to figure it out myself. Could not imagine that it would be that lucky, simple and tricky. I tried restarting VM Ware services, logging Off an On to system, restarting the machine but nothing helped me. So below is the solution that worked for me.

Solution: I recalled the changes i have done in my physical machine and found that few days back i have installed some automatic windows updates. In some cases, these update can really make a big trouble for you. It was nearly around 100 updates and it was not easy to look for each update to check if that effected VMWare. Luckily i applied a filter on my installed windows updates and uninstalled one of Windows Security Update, restarted my physical machine and then ran again the VMWare Workstation. Boooom..... It worked like a charm.

Meanwhile i decided to write this down to my blog before its too late and i forgot or get lazy to write it down on next day. It may be helpful for someone who is running with the same problem as its very rare error. If the above fix do not work for you, try reinstalling the VMWare Workstation.

 Below is the security update that i have uninstalled and rebooted my machine.



Security Update URL : https://support.microsoft.com/en-us/kb/3170106

Enjoy...!

Wednesday, July 20, 2016

SharePoint Web Services Error : An item with the same key has already been added

Hi There,


Recently i found that none of my SharePoint 2013 application services are working. Crashing and throwing unknown multiple kind of errors in event viewer. One of the famous error that i found was below with Event ID 3.

[code]WebHost failed to process a request. Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/47208365 Exception: System.ArgumentException: An item with the same key has already been added. at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) Process Name: w3wp Process ID: 12724 [/code]


While troubleshooting i noticed that none of SharePoint Web Services are browsing and crashing with below error. I knew that it isn't any SharePoint specific error so i tried to recall the changes i have done on server.

Server Error in '/925bc7e108ff47198283782382a09c0d' Application.


An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: An item with the same key has already been added.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentException: An item with the same key has already been added.]
   System.Runtime.AsyncResult.End(IAsyncResult result) +622882
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +196075
   System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +166




Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440




Resolution:

I noticed that somehow during troubleshooting of some other bug i removed the HTTPS bindings from IIS for SharePoint Web Services on Port 32844 which is must even if its not being used by SharePoint. I ran the below Command Prompt command and boom. The services are back.


[code]appcmd set site /site.name:"SharePoint Web Services" /+bindings.[protocol='https',bindingInformation='*:32844:'][/code]





Hope it help someone.

Happy SharePointing...!

Friday, July 15, 2016

Could not load file or assembly 'Microsoft.Workflow.Client

This issue was really a headache for me today. In my farm of four servers i have 2 WFE and 2 APP servers (of course a DB server separately). I have configured Workflow Manager on 1 APP server and Workflow Manager Client on all of the remaining servers. Suddenly i started getting error on workflows and the GUID lead me to the below ULS logs of SharePoint.

[code]07/15/2016 23:28:06.77 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Logging Correlation Data xmnv Medium Name=Request (GET:http://mysharepointapplication:80/newsite/test/_layouts/15/Workflow.aspx?ID=20&List=%7B18957A04-11A4-4016-9404-B1D3897619EF%7D&Source=http%3A%2F%2Fmysharepointapplication%2Fit%2Fsystems%2Fsystems%2Ftest%2FLists%2FCustom%2520List%2FAllItems%2Easpx%3FInitialTabId%3DRibbon%252ERead%26VisibilityContext%3DWSSTabPersistence) da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.77 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Authentication Authorization agb9s Medium Non-OAuth request. IsAuthenticated=True, UserIdentityName=0#.w|mydomain\username, ClaimsCount=24 da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.77 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Logging Correlation Data xmnv Medium Site=/ da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High UserAgent not available, file operations may not be optimized. at Microsoft.SharePoint.SPFileStreamManager.CreateCobaltStreamContainer(SPFileStreamStore spfs, ILockBytes ilb, Boolean copyOnFirstWrite, Boolean disposeIlb) at Microsoft.SharePoint.SPFileStreamManager.SetInputLockBytes(SPFileInfo& fileInfo, SqlSession session, PrefetchResult prefetchResult) at Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocumentRowset(Guid databaseId, SqlSession session, SPFileStreamManager spfstm, Object[] metadataRow, SPRowset contentRowset, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres) at Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32 rowOrd, Object ospFileStmMgr, SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...) at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Byte bMainFileRequest, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion, String& pbstrTimeLastModified, String& pbstrContent, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, ... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder, Guid& pgDocScopeId) at Microsoft.SharePoint.Library.SPRequestInternalClass.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Byte bMainFileRequest, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion, String& pbstrTimeLastModified, String& pbstrContent, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbst... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...rRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder, Guid& pgDocScopeId) at Microsoft.SharePoint.Library.SPRequest.GetFileAndMetaInfo(String bstrUrl, Byte bPageView, Byte bPageMode, Byte bGetBuildDependencySet, String bstrCurrentFolderUrl, Int32 iRequestVersion, Byte bMainFileRequest, Boolean& pbCanCustomizePages, Boolean& pbCanPersonalizeWebParts, Boolean& pbCanAddDeleteWebParts, Boolean& pbGhostedDocument, Boolean& pbDefaultToPersonal, Boolean& pbIsWebWelcomePage, String& pbstrSiteRoot, Guid& pgSiteId, UInt32& pdwVersion,... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ... String& pbstrTimeLastModified, String& pbstrContent, UInt32& pdwPartCount, Object& pvarMetaData, Object& pvarMultipleMeetingDoclibRootFolders, String& pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& pdwItemId, Int64& pllListFlags, Boolean& pbAccessDenied, Guid& pgDocid, Byte& piLevel, UInt64& ppermMask, Object& pvarBuildDependencySet, UInt32& pdwNumBuildDependencies, Object& pvarBuildDependencies, String& pbstrFolderUrl, String& pbstrContentTypeOrder, Guid& pgDocScopeId) at Microsoft.SharePoint.SPWeb.GetWebPartPageContent(Uri pageUrl, Int32 pageVersion, PageView requestedView, HttpContext context, Boolean forRender, Boolean includeHidden, Boolean mainFileRequest, Boolean fetchDependencyInformation, Boolean& ghostedPage, String& siteRoot, Guid& siteId, Int64& bytes, ... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...Guid& docId, UInt32& docVersion, String& timeLastModified, Byte& level, Object& buildDependencySetData, UInt32& dependencyCount, Object& buildDependencies, SPWebPartCollectionInitialState& initialState, Object& oMultipleMeetingDoclibRootFolders, String& redirectUrl, Boolean& ObjectIsList, Guid& listId) at Microsoft.SharePoint.ApplicationRuntime.SPRequestModuleData.FetchWebPartPageInformationForInit(HttpContext context, SPWeb spweb, Boolean mainFileRequest, String path, Boolean impersonate, Boolean& isAppWeb, Boolean& fGhostedPage, Guid& docId, UInt32& docVersion, String& timeLastModified, SPFileLevel& spLevel, String& masterPageUrl, String& customMasterPageUrl, String& webUrl, String& siteUrl, Guid& siteId, Object& buildDependencySetData, SPWebPartCollectionInitialState& initialState, ... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...String& siteRoot, String& redirectUrl, Object& oMultipleMeetingDoclibRootFolders, Boolean& objectIsList, Guid& listId, Int64& bytes) at Microsoft.SharePoint.ApplicationRuntime.SPRequestModuleData.GetWebPartPageData(HttpContext context, String path, Boolean throwIfFileNotFound) at Microsoft.SharePoint.ApplicationRuntime.SPVirtualPathProvider.GetCacheKey(String virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithN... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...oAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) at System.Web.UI.Page.ApplyMasterPage() at System.Web.UI.Page.PerformPreInit() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean in... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...cludeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error) at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb) at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeReque... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files ak8dj High ...stContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags) da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.78 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Files aiv4w Medium Spent 0 ms to bind 29798 byte file stream da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.80 w3wp.exe (0x0E40) 0x2B54 Web Content Management Publishing 7fz3 Medium Setting [Display] as the FormContext.FormMode for the current page da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General 8nca Medium Application error when access /_layouts/15/Workflow.aspx, Error=Could not load file or assembly 'Microsoft.Workflow.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateByMonitoringParameter(Guid monitoringParameter, Int32 offset, Int32 count, Boolean checkPermissions, Nullable`1 secondaryMonitoringParameter) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId, Int32 offset) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId) at Microsoft.SharePoint.Workf... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General 8nca Medium ...lowServices.ApplicationPages.WorkflowPageBase.ConstructStatusArraysWF4(ArrayList running, ArrayList completed, Boolean onlyMyWorkflows) at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.ConstructStatusArrays() at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Runtime tkau Unexpected System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Workflow.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateByMonitoringParameter(Guid monitoringParameter, Int32 offset, Int32 count, Boolean checkPermissions, Nullable`1 secondaryMonitoringParameter) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId, Int32 offset) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId) at Microsoft.SharePoint.WorkflowServices.ApplicationPages.W... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Runtime tkau Unexpected ...orkflowPageBase.ConstructStatusArraysWF4(ArrayList running, ArrayList completed, Boolean onlyMyWorkflows) at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.ConstructStatusArrays() at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General ajlz0 High Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Workflow.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Workflow.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateByMonitoringParameter(Guid monitoringParameter, Int32 offset, Int32 count, Boolean checkPermissions, Nullable`1 secondaryMonitoringParameter) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.Enum... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General ajlz0 High ...erateInstancesForListItem(Guid listId, Int32 itemId, Int32 offset) at Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider.EnumerateInstancesForListItem(Guid listId, Int32 itemId) at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPageBase.ConstructStatusArraysWF4(ArrayList running, ArrayList completed, Boolean onlyMyWorkflows) at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.ConstructStatusArrays() at Microsoft.SharePoint.WorkflowServices.ApplicationPages.WorkflowPage.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.HandleError(Exception e) at System.W... da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83* w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General ajlz0 High ...eb.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation General aat87 Monitorable da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Micro Trace uls4 Medium Micro Trace Tags: 0 nasq,2 agb9s,20 ak8dj,12 7fz3,29 8nca,0 tkau,0 ajlz0,0 aat87 da1f909d-545f-60b2-1cdd-8923ed950a7a 07/15/2016 23:28:06.83 w3wp.exe (0x0E40) 0x2B54 SharePoint Foundation Monitoring b4ly Medium Leaving Monitored Scope (Request (GET:http://mysharepointapplication:80/newsite/test/_layouts/15/Workflow.aspx?ID=20&List=%7B18957A04-11A4-4016-9404-B1D3897619EF%7D&Source=http%3A%2F%2Fmysharepointapplication%2Fit%2Fsystems%2Fsystems%2Ftest%2FLists%2FCustom%2520List%2FAllItems%2Easpx%3FInitialTabId%3DRibbon%252ERead%26VisibilityContext%3DWSSTabPersistence)). Execution Time=69.4163 da1f909d-545f-60b2-1cdd-8923ed950a7a [/code]


I would really like to thank Stephan Bren for answering here and it worked for me perfectly fine. Below are the steps i followed and it worked. You may need to do further steps in case the issue do not fix.

  1. Install hotfix KB2880963.
  2. On the application server hosting Workflow Manager 2013, stop and restart these services:
    • Service Bus GatewayService
    • Bus Message Broker
    • Workflow Manager Backend
  3. Lastly, restart IIS on the WFEs.
References
Notes
  • After installing this hotfix on all of the SharePoint 2013 servers, you may find that running the SharePoint Products Configuration Wizard returns an error:
    Error: Some farm products and patches were not detected on this or other servers. If products or patches are missing locally...
    If this occurs, execute Get-SPProduct -Local on each of the machines identified in the error message.  It may take several minutes for this command to finish.
  • In Solution Step 2), above, I mention restarting workflow services.  It's not clear to me whether all of them need to be restarted, one or more of them, or maybe just restarting IIS, or some other combination of these.  Whichever the case may be, this is the combination I did to recover from experiencing an error clicking on Workflows for a list item, after installing the hotfix.  This approach worked for resolving this problem on both my development and production farms.

Friday, April 29, 2016

How to get custom user profile property from SharePoint User Profile Service using JavaScript AJAX client side script

Hi There,

SharePoint provides a wonderful facility of client side scripts to get data from SharePoint objects. You can get custom user profile property from SharePoint User Profile Service using JavaScript AJAX calls. Below is an example.

I have an AD property with name "Initials" that do not comes in SharePoint OOTB  User Profile Service and you have to bind it manually.

I have set its internal name also "Initials" in my User Profile Service while binding it. We'll call this property using the same name. Remember that, you can only call a User Profile Property from its internal name.


I have bonded it with "Initials" attribute of AD and set the Direction to Import. Click Add.



Now the custom property is appearing when i edit any user profile.


Below is my JavaScript code.

[code]//Display User profile properties function getMyUserProfile(success, error) { var siteUrl = _spPageContextInfo.siteAbsoluteUrl; //You can replace this with your site URL too. i.e http://anysite.com $.ajax({ url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { var json = $.parseJSON(JSON.stringify(data.d)); alert("Hello " + json.DisplayName + " Your Job Title Is : " + json.Title + " Profile Picture URL is :"+ json.PictureUrl + " MySite URL is :"+ json.PersonalUrl); for (var i = 0; i < data.d.UserProfileProperties.results.length; i++) { if (data.d.UserProfileProperties.results[i].Key == "Initials") { alert("Your Custom Property Initials is : " + data.d.UserProfileProperties.results[i].Value); } } }, error: error }); } // Usage getMyUserProfile(function (properties) {}, function (data) { console.log(JSON.stringify(data)); }); [/code]
Boom...! It worked for me.

You can check some suggested codes here too which worked fine and provide another way to use the same code. I am also posting that samples below.

Sample 1:

[code]SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js');

    var userProfileProperties;

    function getUserProperties() {
    var clientContext = new SP.ClientContext.get_current();
    var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
    userProfileProperties = peopleManager.getMyProperties();
    clientContext.load(userProfileProperties);
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
    }
    function onRequestSuccess() {
    var Bild = userProfileProperties.get_userProfileProperties()['PictureURL']
    document.getElementById("div").innerHTML = userProfileProperties.get_userProfileProperties()['WorkEmail'];
    document.getElementById("div1").innerHTML = userProfileProperties.get_userProfileProperties()['PreferredName'];
    document.getElementById("div2").innerHTML = userProfileProperties.get_userProfileProperties()['WorkPhone'];
    $("#bild").attr('src', Bild);
    }

    function onRequestFail(sender, args) { alert( args.get_message());}[/code]

Sample 2:

[code]<script type="text/javascript">


    var workEmail = "";
    var EmployeeID = "";
    var Division = "";
    var userDisplayName = "";
    var AccountName = "";

    $.ajax({

        url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties",
        headers: { Accept: "application/json;odata=verbose" },
        success: function (data) {
            try {
                //Get properties from user profile Json response
                userDisplayName = data.d.DisplayName;
                AccountName = data.d.AccountName;
                var properties = data.d.UserProfileProperties.results;
                for (var i = 0; i < properties.length; i++) {

                    if (property.Key == "WorkEmail") {
                        workEmail = property.Value;
                    }

                    if (property.Key == "EmployeeID") {
                        EmployeeID = property.Value;
                    }
                    if (property.Key == "Division") {
                        Division = property.Value;
                    }

                }
                $('#AccountName').text(AccountName);
                $('#userDisplayName').text(userDisplayName);
                $('#EmployeeID').text(EmployeeID);
                $('#workEmail').text(workEmail);
                $('#Division').text(Division);


            } catch (err2) {
                //alert(JSON.stringify(err2));
            }
        },
        error: function (jQxhr, errorCode, errorThrown) {
            alert(errorThrown);
        }
    });

</script>

<br />
<h2>
<strong>Employee Details</strong></h2>
<br />
AccountName   <span id="AccountName"></span>
DisplayName   <span id="userDisplayName"></span>
EmployeeID    <span id="EmployeeID"></span>
Email Address <span id="workEmail"></span>
Division      <span id="Division"></span></div>[/code]

SharePoint Client Side REST API 500 Internal Server Error

Hi There,

I have been now in code again since last two months and facing the developer life challenges :P .

I am calling the GetMyProperties from client side REST API method "/_api/SP.UserProfiles.PeopleManager/GetMyProperties" but my site is throwing 500 internal server error or 400 bad request. Life time annoying errors :-/ . My code was working fine on my dev machine but not on client's server, so apparently its a server configuration issue.

Things to check when you get 500 Internal Server Error or similar IIS erros on "/_api/XXXXXXXXXXXXXXXX" or same kind of issues is, 

1. Check your User Profile Service is running properly
2. Check your my site is configured properly
3. Check your my site is configured in my site host application in User Profile Service

In my case, the issue was, my MySite was not configured in User Profile Service and when i open MySite it throws error and a correlation ID. So i added my MySite in User Profile Service and also enabled Self-Service Site Creation on my MySite. After that my MySite appeared fine and so my code also worked fine and returned me the required data.


[code] //Display User profile properties on top header function getMyUserProfile(success, error) { var siteUrl = _spPageContextInfo.siteAbsoluteUrl; $.ajax({ url: siteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { var json = $.parseJSON(JSON.stringify(data.d)); alert(json.DisplayName); }, error: error }); } [/code]


    

Wednesday, April 27, 2016

Traverse all users permissions on SharePoint 2010,2013 Site Collection PowerShell

Hi There,

I have found a very useful PowerShell script to traverse all users permissions on SharePoint 2010,2013 Site Collection using PowerShell. Thanks to Johan Mayer for updating the PowerShell code and making it more useful.

This PowerShell code will traverse or extract all users having permissions through any of SharePoint group and any level of permission. For example, if a User has permissions using three groups Readers, Contributors and Owners, it will show all groups one by one and describe the user permissions level in each group. Sample screenshot below.



PowerShell Script:

You can copy and paste this PowerShell script in a simple notepad file and save as .ps1 file. Now run SharePoint Management Shell and point to the file where you have just saved.

This script will traverse users permissions inside the lists/libraries too. You can filter the data once exported in CSV.

[code]function Get-SPUserEffectivePermissions( [object[]]$users, [Microsoft.SharePoint.SPSecurableObject]$InputObject) { begin { } process { $so = $InputObject if ($so -eq $null) { $so = $_ } if ($so -isnot [Microsoft.SharePoint.SPSecurableObject]) { throw "A valid SPWeb, SPList, or SPListItem must be provided." } foreach ($user in $users) { # Set the users login name $loginName = $user if ($user -is [Microsoft.SharePoint.SPUser] -or $user -is [PSCustomObject]) { $loginName = $user.LoginName } if ($loginName -eq $null) { throw "The provided user is null or empty. Specify a valid SPUser object or login name." } # Get the users permission details. $permInfo = $so.GetUserEffectivePermissionInfo($loginName) # Determine the URL to the securable object being evaluated $resource = $null if ($so -is [Microsoft.SharePoint.SPWeb]) { $resource = $so.Url } elseif ($so -is [Microsoft.SharePoint.SPList]) { $resource = $so.ParentWeb.Site.MakeFullUrl($so.RootFolder.ServerRelativeUrl) } elseif ($so -is [Microsoft.SharePoint.SPListItem]) { $resource = $so.ParentList.ParentWeb.Site.MakeFullUrl($so.Url) } # Get the role assignments and iterate through them $roleAssignments = $permInfo.RoleAssignments if ($roleAssignments.Count -gt 0) { foreach ($roleAssignment in $roleAssignments) { $member = $roleAssignment.Member # Build a string array of all the permission level names $permName = @() foreach ($definition in $roleAssignment.RoleDefinitionBindings) { $permName += $definition.Name } # Determine how the users permissions were assigned $assignment = "Direct Assignment" if ($member -is [Microsoft.SharePoint.SPGroup]) { $assignment = $member.Name } else { if ($member.IsDomainGroup -and ($member.LoginName -ne $loginName)) { $assignment = $member.LoginName } } # Create a hash table with all the data $hash = @{ Resource = $resource "Resource Type" = $so.GetType().Name User = $loginName Permission = $permName -join ", " "Granted By" = $assignment } # Convert the hash to an object and output to the pipeline New-Object PSObject -Property $hash } } } } end {} } $site = $gc | Get-SPSite http://localhost:2020 $groups = $site.RootWeb.sitegroups foreach ($grp in $groups) { foreach ($user in $grp.users) { $user = $user.LoginName $webPermissions = $site | Get-SPWeb –Limit All | Get-SPUserEffectivePermissions $user $listPermissions = $site | Get-SPWeb –Limit All | %{$_.Lists | Get-SPUserEffectivePermissions $user} ($webPermissions + $listPermissions) | ConvertTo-Csv -NoTypeInformation | Add-Content -Path c:\perms.csv } Add-Content -Path c:\perms.csv -Value $justData -Encoding UTF8 } $site.Dispose() $gc | Stop-SPAssignment[/code]

You can also download the script from here.

Enjoy...!

Friday, April 15, 2016

SharePoint 2013 Blog Post Error : TypeError: Unable to get property 'id' of undefined or null reference

Hi There,

Its a brand new installation with no customization on SharePoint site. I created a blog type subsite called "News" in SharePoint and faced the below error. This error comes up when i created a blog post in SharePoint from User1 account and then open the same post with User2 account which had read only permissions on the site. 



TypeError: Unable to get property 'id' of undefined or null reference
OR
TypeError: Unable to get property 'trim' of undefined or null reference

My current version of SharePoint was RTM 15.0.4420.1017. I installed the SharePoint Server SP1 (15.0.4569.1000) and the error "TypeError: Unable to get property 'id' of undefined or null reference" went away. Mean while i tested the same thing on another RTM version of SharePoint where it worked fine without any issue and installation of SP1. Hope it will help someone...!

Happy SharePointing...!