Proper Deployment Steps for SharePoint Timer Job Service

I created a share point time job using visual studio 2010. I deployed that job using VS and i got some error while debugging this job. I rectified the error and again deployed this but when i debugged again my timer job picking up the old references. For my wonder i deployed this again and again but same issue was still there even i manually deployed the job and referenced assemblies in to GAC. At last i removed each and ever reference manually and again redeployed this but the problem was pathetic and my recent changes were not picked up by timer job. Finally i came to know that “SharePoint 2010 Timer” service holds the old reference even i redeployed the solution by visual studio. So below are the steps that how i rectified this issue and the proper way of deployment of SharePoint Timer job so that if you modify the timer job code and redeployed this then new changes should be picked up by timer job.

  1. Deploy the timer job first. (Either directly by Visual Studio or Power Shell script or STSADM using wsp).
  2. Go to Start > Run (Windows Key+R)
  3. Type Services.msc and hit enter or click on OK.
  4. Now inside service console locate “SharePoint 2010 Timer”.
  5. Stop and Start service (You can directly use Restart option).
  6. Now go to Start > Run (Windows+R) again
  7. Type IISRESET and hit enter.
  8. After iisreset successfully your new modifications inside timer job code will be picked up and service will run smooth(If code written for timer job is correct.).

Happy SharePointing 🙂 Enjoy 🙂

Search Crawling Error “The filtering process could not load the item…” in SharePoint 2010 : Resolved

“The filtering process could not load the item. This is possibly caused by an unrecognized item format or item corruption.”
In our production server this warning was generating with many items while crawling sites for search. Due to this we were unable to find the content of our custom pages during search. After a long period of time we could get the actual issue. We tried each and every settings related to search in Share Point server with no luck. We also goggled a hell lot of topics regarding this but couldn’t resolve this. While goggling i found some interesting links those says that this issue comes due to the missing or corrupt installation of pdf iFilter. Though we don’t have any pdf document anywhere on the site even then we installed the pdf iFilter correctly two times with no luck. More interesting thing was that this error was generating for Share Point server’s default pages like AllItems.aspx etc. This search crawling was running successfully on all other servers. So where was the actual problem ?
Problem: While upgrading this server a Microsoft Office 2010 update corrupt the Filter Packs of this server and this corruption was causing the crawling issue. Generally people aware of pdf iFilter but apart from this iFilter there are other filters installed too for smooth processing of search crawling and they were corrupted however in our case.
Resolution: I just download the Microsoft Office 2010 Filter Packs (64 bit) and reinstall them again. After that reset the search index and crawl again and voila i got my search crawling smooth without any warning and errors. Everything worked fine after that. Download link for Microsoft Office 2010 Filter Packs is mentioned below:
http://www.microsoft.com/download/en/details.aspx?id=17062
Enjoy… Happy SharePointing 🙂 ….

Set Welcome Page using PowerShell : SharePoint 2010

By default a SharePoint 2010 publishing site uses default.aspx as its welcome page. There are so many conditions where we use our custom web part page as the default page for our publishing site in place of general default.aspx. The best example for this is an application dashboard as the default page. Though its very easy to set the welcome page in a SharePoint site by navigating to Site Settings and under Look and Feel section click on Welcome Page.

Now the question is why i wrote power-shell script for such a simple task.

Answer 1: I want a one click deployment solution for my custom code that includes features, event receivers, web parts etc. I don’t want to remember steps, just i run a batch file and execute everything inside from that batch file.

Answer 2: In my solution i have custom pages and i wrote the deployment script to create those pages. During development if we change any page for java-script, CSS etc. then we need to redeploy the pages to check the implementation. So we need to delete all pages first and then redeploy them otherwise pages so the double instance of each web parts inside that. Well we know that you can’t delete a page directly that is set as welcome page in SharePoint site so in this case you need to set another page as welcome page first then delete the page you want to. So during my development cycle this was very irritating that before deployment of my custom pages i need to first  set Under_Construction.aspx page as my welcome page then delete my actual welcome page then deploy custom pages and then again set the actual page as welcome page. What is your machine is slow and after any deployment it runs pathetically slow..

Oh my god it sucks.. So for all this i wrote a script to set welcome page so that before and after the deployment of pages i could run this and rest of the work it do automatically. So below is the script:

Add-PsSnapin Microsoft.SharePoint.PowerShell
$assignment=Start-SPAssignment
$web=Get-SPWeb -Identity “http://kailash1689new:9007” -AssignmentCollection $assignment
$rootFolder=$web.RootFolder
$rootFolder.WelcomePage=”Pages/Dashboard.aspx”
$rootFolder.Update()
Stop-SPAssignment $assignment
$web.Update()
$web.Dispose()
Write-Host ‘Welcome Page Set Successfully…’
Write-Host ‘Press any key to exit…’
$x=$Host.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”)
$Host.SetShouldExit(1)

Hide View All Site Content and Recycle Bin in Quick Launch SharePoint 2010: Resolved

When I worked on MOSS 2007 I wrote an article regarding Hide View All Site Content and Recycle Bin in Quick Launch: Resolved and this article is one of the most popular article @ my blog.

But that article was suitable only for MOSS 2007. As there are lots of changes from MOSS 2007 to SharePoint 2010, so that article can’t be applied on SharePoint 2010.

One blog surfer told me regarding this and then i decide to dig out that how will we achieve same thing in SharePoint 2010. So after doing some research I could make it happen in SharePoint 2010. Below are the steps to achieve this:

1. Open Notepad and paste following style inside the notepad file:

<style>

.s4-specialNavLinkList {

display:none;

}

</style>

2. Now save this text file on your system.

3. Open the site where you want to hide Recycle Bin and All Site Content links and upload saved text file in to a document library.

4. After uploading the file click on the name of the file inside document library. Now a dialog box will open and ask for Read Only or Edit Mode.

5. Just select Read Only mode and ok.

6. Text fill will display inside browser. Copy the URL of text file from address bar of browser.

7. No open SharePoint 2010 page where you want to hide Recycle Bin and All Site Content Links.

8. Put Page in edit mode and add a Content Editor Web Part (This web part is inside Media and Content Category in SharePoint 2010) inside the page.

9. Now click on Edit Web Part from context menu.

10. Inside Content Link text box paste the URL u copied earlier in step 6.

11. Click on Ok and you are done.

Happy SharePointing 🙂

Add Safe Control Entries to SharePoint 2010 Web Parts using VS2010

I was reviewing a SharePoint solution and found that a web part inside that solution has poor naming conventions so I decide to rename the web parts for giving the proper names to them.

I changed the necessary references in different files of web part (I’ll mention them in a separate blog post). Now after renaming the web part I deployed it on site and then tried to add it in a web part page and it simply throws me the error.

Type is not registered as safe“. Well at first glance I decided to see me safe controls entries inside my site’s web.config file and I was right that namespace part was wrong in web.config file. It was pointing to earlier namespace and class name. Humnnnn so if I changed this entry manually then it works fine but I need to automate the deployment process and I wanted to write the correct safe controls entries inside web.config whenever we deploy the web part. Well so question arises where to set my safe control entries inside my SharePoint solution. Well after analysing that I came to the solution. So below are the steps described for that:

1. Open your SharePoint web part project inside visual studio 2010.

2. Select the web part folder for which you want to change the safe control entries in web.config file.

3. Press F4 to open properties window (I am not talking here for property page.).

4. In properties windows there is last entry of properties displaying as “Safe Control Entries

5. Click on the eclipse sign in front of “Safe Control Entries” value.

6. Inside “Safe Control Entries” pop up window, check for Namespace properties inside SafeControlEntry1 properties panel.

7. Change value of namespace property according to your namespace and class and click ok.

8. Save and build the solution and deploy it again.

9. Now after successful deployment check web.config of site and voilà you’ll find the correct safe type entries of your web part.

Happy Share Pointing J

Microsoft made the excellent integration of SharePoint with Visual Studio 2010. Good to see that.

In my next blogs I’ll come with these types of enhancements that visual studio provides for SharePoint 2010.

Installing assembly in GAC in Windows Server 2008 : Resolved

I developed an event handler and need to deploy it on production server. My production server is built on Windows 2008 Enterprise Server 64 Bit and there was only one installation on server i.e. SharePoint Server 2010. Now I need to install my assembly in to GAC. I copied my .dll to production server. Then I opened c:\windows\assembly and drag drops my assembly in to GAC (c:\windows\assembly folder). But nothing happened and my assembly couldn’t install in GAC 😦

Drag and drop was not working. So second alternative was to use gautil.exe to install the assembly inside GAC but as it was production server so there wasn’t any installation of visual studio and hence there was no SDK installed therefore there wasn’t such exe like gacutil.exe. Again that was a problem. Now I worked on why drag and drop is not working. I searched here and there and follow some articles but nothing helped me. I disable UAC and restart server but it doesn’t work. I opened console and explorer using run as administrator but nothing helped me. Then I copied gacutil.exe file from my development machine to production server but I couldn’t run it (Though lastly this technique worked for me).So finally I resolved this issue and below are the directions for how to resolve this?

1. First check that if production server is of 32 bit or 64 bit?

2. If it is 64 bit then open folder “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64

But if it is 32 bit then open folder “C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin

3. Copy 2 files i.e. gacutil.exe & gacutil.exe.config

4. Paste these files to any location of production server.

5. Your gacutil.exe is now ready to run and u can install assembly in to GAC using this small utility.

 Points to Remember

* When you drag and drop assembly in GAC it won’t give proper error messages (Like targeting framework error) if it has any so better to use gacutil to install assembly.

* gacutil.exe doesn’t run standalone rather it needs a configuration file to run i.e. gacutil.exe.config

Command Line Error by STSADM : Resolved

I was executing a command using stsadm and when I hit enter it was displaying an error stating that “Command Line Error”. Everything was perfect from my end but it was weird to getting this error. So finally I could resolve this. For information how to resolve this find my earlier blog post here.

Though it was for a different problem but resolution of both problems is same.

Enjoy SharePointing……….

Resolved: The given assembly or codebase was invalid error by stsadm command

I was trying to register custom profiledeletehandler by using stsadm command line utility. My command, code and assembly were perfect. But even then when I was trying to execute stsadm then it was displaying “The given assembly or codebase was invalid”.

Humnnn what could be the problem then after doing some research I came to know that I wrote the part of the command in notepad first and then copy/paste this part in command line. OMG, that was some encoding problem while copy/pasting the command.

Though if you delete the stsadm command and retype this in command line console then both (earlier & retyped) will look same. But this was only and major difference and solve the problem.

Solution: Please type the whole command by your own including each and everything.

Moral of the Story:

1. Avoid copy/pasting the stsadm command from other application as you can be the victim of this type of problem.

2. Always do check for PublicKeyToken values (If u are using assembly reference) twice and other spelling mistakes in stsadm command, as it can be the cause of these type of problems.

Microsoft Visio 2010 crashes very frequently : Resolved

I was working on DFD of an on-going project. For DFD designing I chose Microsoft Visio 2010 but after doing some work on that I came to know that Visio crashes very frequently. Believe me that for callout descriptions I need to copy paste a text and for achieving this task Visio crashed more than 20 times. Totally frustrating. Well I restarted the machine and somehow managed the crashes.

On very next day I need to update that DFD and again same thing happen to me as whenever I click on save, Visio got crashed. So I decide to analyse the problem of Visio and tried to fix it. So from that very time my Visio 2010 is working fine. Below are the description of what I analysed and fixed.

When we install Microsoft Visio 2010 in to system then by default a new add-in installed and activate inside Visio i.e. Send to Bluetooth. As when you open the Visio you will find the last tab as Add-Ins and when you click on that you will find that there is Send to Bluetooth in ribbon menu. This is the root cause of Visio crashing. So I disabled this and Visio working fine for me after doing this. Find steps below:

  1. Go to File > Options
  2. Visio Options window will pop up
  3. On left hand side menu of pop up window, click on Add-Ins
  4. Now on right hand side area make sure to select COM Add-Ins options in Manage dropdown box.
  5. Click on Go button that is in front of Manage dropdown box.
  6. COM-Add-Ins window will pop up
  7. In the list of available add-ins, unselect the checkbox in front of Send to Bluetooth.
  8. Click on OK button.
  9. Restart Visio 2010 and you see that now there is no Add-Ins menu.
  10. You are now ready to work smoothly.

Cheers 🙂

Call Hierarchy : A handy feature in Visual Studio 2010

Suppose we have a solution that contains different dependent projects. We can face 2 most common situation here:

Situation 1: We have a method that we need to change by modifying the definition of that method or just we want to check that which other methods are calling this method.

Situation 2: We have a method that contains so many lines of codes and we need to check that inside this method which all other methods are calling as method is too large and we don’t want to go line by line for this.

Before VS 2010, for situation 1, we need to search the method name in whole solution then we can find the call of this solution in search window but the drawback of this approach is that if you have overloaded methods then in search result all methods will display and you need to take extra care for that.

Now in VS 2010, Microsoft provided a beautiful menu and context command to help these situations. Below are the steps to use these helpful commands:

  1. First you need to open your solution.
  2. Now open the file, where the method is located and needs to be checked.
  3. Go to View > Call Hierarchy
  4. Call Hierarchy window will open on bottom side, in this window choose My Solution from drop down. (You can also choose Current Project, Current Document depending upon your needs.)
  5. Now right click the method name in file opened and click on “View Call Hierarchy” from context menu.
  6. Your Call Hierarchy window will populate with details like Calls To “Method Name” and Calls From “Method Name” you can just expand these nodes and check all the incoming and outgoing call from this particular method.

Enjoy this new feature 🙂