SharePoint search is returning 500 internal server error page : Resolved

Recently i was working on a Intranet Portal and most part of it was based on documents collaboration. So to easily find a document i configured search for the site. I created a new content source in existing search service application and crawl the source. It was crawled successfully without showing an error or warning, but when i opened the site in IE i was presented by an 500 internal server error page. I tried one more time and same result, i suspect that there is something fishy in IIS (may be application or app pool is stopped). To my surprise there was nothing like that, i reset the IIS but same result. After checking the log file i found this weird entry.

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure “Resources.lutron.core.resources” was correctly embedded or linked into assembly “App_GlobalResources.0whxr_of” at compile time, or that all the satellite assemblies required are loadable and fully signed.    at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)     at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)     at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)     at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)     at System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture)     at System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName)     at System.Web.HttpContext.GetGlobalResourceObject(String classKey, String resourceKey, CultureInfo culture)     at Microsoft.SharePoint.Search.SPSatelliteResourceExpressionBuilder.GetResource(String classKey, String resourceKey)     at ASP._layouts_accessdenied_aspx.__BuildControlltAccessDeniedCaption()

After sometime i opened the site in Chrome and search was working fine there same was with Firefox. So i thought that there is problem with browser not with SharePoint server. After digging in to IE settings i came to know that there wasn’t any default language set for my IE (Might be i removed this for some testing purpose.)

Every user has a search preference inside SharePoint site and it can be accessed through below link.

http://My_SharePoint_Site/_layouts/EditUserPref.aspx

In this page, by default search language is set as ‘Search using my browser’s language‘. Other option is ‘Search using the following languages (maximum of five)‘. So if the option 1 (default) is selected then there should be a default language set in your browser otherwise you’ll get 500 internal server error.

In case option 2 is selected, then search is not dependent on browser language preference. In my case i just set the browser default language in place of opt for option 2. Below are the steps.

  1. Tools > Internet Options.
  2. Under General tab, click on languages button.
  3. Inside Language Preference window, add a language (in my case it was English (United States) ). If you add multiple languages in this window then the first one will be treated as the default language for browser.

*You can also opt for option 2 mentioned above as per your choice.

Happy SharePointing 🙂

Advertisements

Update custom list’s feature reference | Update custom list’s feature id reference.

Disclaimer: Approach used in this blog post is risky and not recommended. The idea of this post is to just understand the insight and sharing my experience with my blog readers. If still you want to try this for any situation then please do this at your own risk.

We earlier created a custom list using list definitions feature in our site. After one month, we decided that the list definition responsible for list creation had to move to another feature to make the feature as the group of alike lists.

After deployment, we found that list was not being opened and was throwing error. So after digging in to log file, I came to know that list was still pointing to previous feature and now that feature didn’t have the reference for the list schema (As we had already moved the reference to the new feature). I was not ready to take risk of deleting the existing list as it was already contained thousands of referenced items. Deleting the list means to do lots of manual work to fix the functionality and to waste the time and effort.

Now there was only one way that if somehow I could change the reference of existing feature id of list to new feature id. But how that was possible??

I couldn’t found a direct way by using code or Power Shell script to change the feature reference of existing list. So I started analyzing and thought that at least there must be some place where SharePoint keeps this configuration and my mind said content database. Now as you know that SharePoint content database is not a piece of cake to understand and it’s very complex to understand. Everything is based on GUID and referencing is too complex to understand. Due to this complexity, Microsoft doesn’t recommend to touch the content database. But for me there was no other way. So below is how I fixed this issue.

  •  In site content database, there is a table (AllLists) that has all such references. This table keeps the relation information of a custom list and feature related with the list.
  • tp_Title‘ column has the name of list(s) and ‘tp_FeatureId‘ column keeps the feature id related to the specific list.
  • My list name was ‘AnnouncementCategory’ and first I perform the below command.

SELECT *  FROM [AllLists] where tp_Title like ‘%Announce%’

This query gave me all related lists result set. After analyzing the result set I came to know that all other related lists are pointing to same feature id but the problematic list was pointing to different feature id (The previous feature).

  • Now I decided to update the feature id value to see the difference. I noted down the current feature-id value at notepad (In case to revert back the changes) and execute below mentioned update command to update the feature id.

update AllLists set tp_FeatureId=’xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’ where tp_ID like ‘%xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%’

tp_FeatureId : This is the feature id of new feature that contains the reference of the existing list. You can get this from your code file (Feature.xml) or from 14 hive (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES).

tp_ID : This is the unique id column in the AllLists table to identify a specific record.

  • After running this command, when I tried to open the problematic list then to my surprise it opened without any error. After that I performed some testing on the list to verify that whether everything is working fine or not.
  • Testing included adding/updating/deleting/content migration and lookup references of list.

For me after spending a couple of hours, it was like bingo. Happy Share Pointing 🙂

Download Files/Images from SharePoint Libraries using PowerShell

I consigned a task to backup all files inside different document libraries of a SharePoint site on hard disk. We need to reorganize the entire site and this site comprises so many document libraries. So downloading documents one by one is a gigantic task as the site has gigs of docs. Alternative option is to open libraries in explorer and start copying them to a place, but this methodology has so many limitations e.g. network speed, installation of office components, much time required etc.
I want to get this job done hastily. So for a moment I thought of Power Shell. I want to give it a try and trust me by using this I was able to download gigs of documents within minute. Below is the code snippet for your reference:

 

######################## Start Variables ########################
######################## Download Files Script######################
$destination = $args[0]
$webUrl = $args[1]

##############################################################
# Replace actual document libraries name with DocLib1, 2, 3 etc.
$listUrls=”DocLib1″,”DocLib2″,”DocLib3″,”DocLib4″,”DocLib5″

$web = Get-SPWeb -Identity $webUrl

foreach($listUrl in $listUrls)
{
$list = $web.GetList($webUrl+”/”+$listUrl)

function ProcessFolder {
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
        #Ensure destination directory
        $destinationfolder = $destination + “/” + $folder.Url
        if (!(Test-Path -path $destinationfolder))
        {
            $dest = New-Item $destinationfolder -type directory
        }
        #Download file
        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + “/” + $file.Name), Create
        $writer = New-Object System.IO.BinaryWriter($stream)
        $writer.write($binary)
        $writer.Close()
        }
}

#Download root files
ProcessFolder($list.RootFolder.Url)
#Download files in folders
foreach ($folder in $list.Folders) {
    ProcessFolder($folder.Url)
}}

 

Copy this to a notepad file and save with extension .ps1 E.g. DownloadFiles.ps1

Open SharePoint Management Shell 2010; navigate to the path of script. Provide destination path as argument 1 and site URL as argument 2 as shown below.  

.\DownloadFiles.ps1 “d:\documents” http://mySite

*This will create separate folders for each document library with library name.

 

Failed to open the default internet browser SharePoint : Resolved

Recently i uninstalled Chrome browser from my machine. After that when i tried to open Central Administration then below mentioned

error popped up as message.
Failed to open the default internet browser. An Internet browser is not  installed or has not been configured to be your default browser
I checked the target of Central Administration and found it was correct i.e. “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\psconfigui.exe” -cmd showcentraladmin”

So issue was that Central Administration application was unable to detect default browser. Though i have 2 different browsers on my machine including IE 9.

Below are the steps to fix the issue. Though these steps are specific to Windows 7 but you can use them with any Windows OS.

  1. Go to Control Panel.
  2. Click on “Default Programs“.
  3. Click on “Set your default programs“.
  4. Click “Internet Explorer” under Programs section (Left hand side in Windows 7) and click on “Set this program as default“.

You are done. Happy SharePointing 🙂

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.

Create Hierarchies Link in SharePoint Variation Site is not working : Resolved

Problem: Inside variation labels, if we click on create hierarchies button nothing happens.

Scenario: I had a publishing site with variation enabled on a specific port. I backed up the site and restore it on a web site hosted on another server. This new website is on different port. Now i created a new variation label inside new site and after creating variation label, when i clicked on Create Hierarchies button nothing got happen. So i started to search the root cause of this problem. I first open the variation link to check the variation settings and here i found that location in the variation home section was pointed to the old server and settings were disabled. Humnnn it meant that this was the root cause of the problem. So question arises that how to change the settings as i wanted to keep all the sites that were earlier created by using variation hierarchies and using GUI there was no option to reset these settings. After searching Google, i couldn’t find any specific things regarding this. Problem was that linking in variation settings was not appropriate. So after spending lots of hours to fix this problem i came to know that there is a hidden relationship list inside the publishing site that has variation functionality. So after tweaking my site URL i got that list. Below are the steps to fix this problem.

1. Append your root site URL like this “http://testserver:9001/relationships%20list/allitems.aspx“.

2. Relationships List will open and here you will see so many entries of (no title) depending upon the earlier sites created.

3. You have to open and view each item until you find the value “F68A02C8-2DCC-4894-B67D-BBAED5A066F9” against the GroupId column.

4. This item has relation link for variation home site and this value will same for all publishing sites having variations.

5. Edit the item.

6. Against ObjectId column fill the URL of root site e.g. http://testserver:9001

7. Give any title and click on OK button.

8. Come out from that list, create a new variation label and then create hierarchies button.

9. Voilà hierarchies are creating now.

 

Exports excel data to SharePoint custom list with desired column names!

So once again I am back with a blog post…

Today we will see that how to import a spreadsheet inside a custom list with defined columns.

We are ready for production deployment for an application. This application contains the master data for cities all over the world. Client provided us the list of 9000 cities that need to be inserted inside master custom list as we know that 9000 entries will take the hell lot of time to add in the list. So how would I do it within the sort span of time?

The only way that I put all the cities inside an excel and then create a new a custom list by importing that excel. So I start the thing. I create a list using import spreadsheet option but ooopsssss all cities updated inside that custom list but when I look at the column name this shows me like Column1, Column2, etc….

This was very disappointing as this list and columns are used in my custom code, and I don’t want to change my code due to this.

SO QUESTION WAS that I want 9000 entries inside custom list with desired column names…

What to do so below are the steps to do that.

 

  • First open the excel sheet.
  • Paste the data inside excel sheet accordingly you want.
  • Now in the first row put the column name that you want the list column name.
  • Remember that between two columns there should not be any column left blank.
  • Now select first cell of the sheet.
  • Click on Insert tab and then click on the table.
  • It will open a Create table window with the selected range of data.
  • Select my table has headers checkbox then ok.
  • Now your sheet is in a table format, and we are on the way.
  • Now open the site and select on create.
  • Create the custom list using import spreadsheet option
  • Give a name of the list and path of the excel sheet and click on import.
  • It will open the excel sheet and a window.
  • Select cell ranges in the drop down and give the range of the cells.
  • Just import and after completing the process we have a custom list with data and desired column names.

Happy SharePointing 🙂

Resolved: Could not load file or assembly ‘Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies…

I have a solution that contains SharePoint dll’s reference. Whenever I run the solution, start page get crash and show me this error.

“Could not load file or assembly ‘Microsoft.SharePoint.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. An attempt was made to load a program with an incorrect format.”

Well every time I run the project it creates Microsoft.SharePoint.Search.dll and Microsoft.SharePoint.Search.xml inside the bin folder and it creates the problem. Well there are lots many things have written on web regarding this problem. I follow all these things but could not get rid of this error. Finally I decided to fix this problem according to my way. So below are the steps to fix this problem permanently.

1.       Inside solution explorer (Visual Studio), select the project and right click on that.

2.       From context menu, click on properties.

3.       When properties page opens, Click on Build Events.

4.       Under Post – build event command line, copy and  paste below lines

cd $(TargetDir)

del Microsoft.SharePoint.Search.dll

del Microsoft.SharePoint.Search.xml

Now save the project, build the project and run. Now above mentioned error will never irritate you. 🙂