Monday, April 19, 2010

Batch file for restarting iis and Asynch service

while developing custom components for MSCRM many times we need to restart IIS and Asynch service, here are handy batch commands
save these to a file with .bat extension and just execute the file when needed


@echo off

echo Restarting IIS...
iisreset
echo IIS Restarted

echo Restarting Microsoft CRM Asynchronous Processing Service...
net stop "Microsoft CRM Asynchronous Processing Service"
net start "Microsoft CRM Asynchronous Processing Service"
echo Microsoft CRM Asynchronous Processing Service restarted !!

or incase of custom workflow development
you can add this command to Pre-Build event commands(this is recomended for single user development server) and give output path directly to assembly\bin folder of MSCRM













From Another .net blog


and






From Another .net blog

Wednesday, March 3, 2010

Programmatically associate workflow to SharePoint list

SPList MySPList = MyWeb.Lists[DocumentLibraryName];
SPList TheTaskList = MyWeb.Lists["Tasks"];
SPList TheHistoryList = MyWeb.Lists["Workflow History"];
SPWorkflowTemplate MyTemplate = null;
foreach (SPWorkflowTemplate template in MyWeb.WorkflowTemplates)
{
if (template.Name == "My Workflow Name")
{
MyTemplate = template;
break;
}
}
SPWorkflowAssociation TheAssociation = SPWorkflowAssociation.CreateListAssociation(MyTemplate, MyTemplate.Name, TheTaskList, TheHistoryList);

MySPList.AddWorkflowAssociation(TheAssociation);
MySPList.Update();


associateWorkflow.AutoStartChange = true ;

Wednesday, February 24, 2010

The key specified to compute a hash value is expired MS CRM error

Error

Actor:
Detail: <error>
  <code>0x8004a106</code>
  <description>The key specified to compute a hash value is expired, only active keys are valid.  Expired Key : CrmKey(Id:709e4e9e-7120-df11-b05c-001372a660a9, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmTicketKey, Expired:True, ValidOn:02/23/2010 11:50:21, ExpiresOn:02/25/2010 11:50:21, CreatedOn:02/23/2010 11:50:21, CreatedBy:domain\username.</description>
  <type>Platform</type>
</error>
Detailed Inner Exception: <error>
  <code>0x8004a106</code>
  <description>The key specified to compute a hash value is expired, only active keys are valid.  Expired Key : CrmKey(Id:709e4e9e-7120-df11-b05c-001372a660a9, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmTicketKey, Expired:True, ValidOn:02/23/2010 11:50:21, ExpiresOn:02/25/2010 11:50:21, CreatedOn:02/23/2010 11:50:21, CreatedBy:domain\username.</description>
  <type>Platform</type>
</error>
Message: Server was unable to process request.

Solution
any of below

   1. run Microsoft.Crm.Tools.WRPCKeyRenewal.exe file located on CRM server at C:\Program Files\Microsoft Dynamics CRM\Tools
   2. Restart MSCRM Synchronous ServiceTechnorati Tags:

Tuesday, February 23, 2010

File not found exception in SharePoint

File not found exception in  SharePoint

I faced this issue many times during working on various sharepoint projects


System.IO.FileNotFoundException: The Web application at http://server/sites/sitecoll/default.aspx could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application. at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri, Boolean contextSite, SPUserToken userToken) at Microsoft.SharePoint.SPSite..ctor(String requestUrl)

i was getting this error from my custom web service deployed at sharepoint server

one nice blog post i found at

http://sharepointguild.blogspot.com/2009/04/systemiofilenotfoundexception-error.html

apart from solution mentioned there i did couple of more changes to my web service
  • Changed the app pool identity from NetworkService to a priviledge user
  •  Changed the custom web service app pool to sharepoint web application app pool
either of these worked for me

.