Archive for category SharePoint 2010
‘Microsoft.SharePoint.Client.Form’ does not contain a constructor that takes 0 arguments – SharePoint 2010 Client Object Model
Posted by Rajanihanth in .Net, Client Object model, SharePoint 2010 on July 13, 2012
To fix this issue, just click here. Thanks, R../
How to get the list of folders and subfolders from a SharePoint document library
Posted by Rajanihanth in SharePoint 2007, SharePoint 2010, Tech Tips-SharePoint on July 13, 2012
There are many ways to get files & folder details from SharePoint (programmatically) but my manager asked me to provide the list of folders and sub folders from a SharePoint document library urgently. So I wanted get an idea to provide the information quickly, after spending few minutes on the web and found this post (I know about the DIR command but didn’t think about the SharePoint UNC). Yes, we can get the details using DOS command with UNC path. 🙂
First of all, we want to know about UNC and the DIR command.
UNC: Universal Naming Convention, a format for specifying the location of resources on a local-area network (LAN). Read more about this here.
Syntax: \\<servername>\<sharename>\<directory>
DIR: Display a list of files and subfolders. Read more about this here.
Syntax: DIR [pathname(s)] [display_format] [file_attributes] [sorted] [time] [options]
To get SharePoint UNC path, just remove http: from the SharePoint url and replace the forward slash with backslash. So my document library path is:
http://ServerName/doccenter/Administration/StepBiStep
then it’s UNC will be like this:
\\ServerName\doccenter\Administration\StepBiStep
Okay.. we will see the steps here, I have created a document library (StepBiStep) for testing purpose.
Step 1: Open the cmd prompt
Step 2: type the following statement in the command-line and press Enter key.
DIR /B /A:D / S [UNC Path] > [File Name]
– /B -Bare format (no heading, file sizes or summary)
– /A:D -Folder file attributes
– /S -Include all subfolders
– [UNC Path] -The path, which you want to get all the folders and subfolders
– [File Name] -A text file name to store the folder details
So our command is looks like this, I have used a text file (FolderLists.txt, which is located in C: drive) to store the details.
DIR /b /A:D /S \\ServerName\doccenter\Administration\StepBiStep > c:\FolderLists.txt
Step 3: It will take few minutes to generate the list. You can open in a Notepad and see..!.
That’s all guys, enjoy! I do welcome your comments. Please leave them here! 🙂
References:
‘Form’ is an ambiguous reference between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’ – SharePoint 2010 Client Object Model
Posted by Rajanihanth in .Net, Client Object model, SharePoint 2010 on July 13, 2012
When you try to use the Client Object Model (SharePoint 2010) with Windows Application in Visual Studio 2010, you might be getting these error messages. (You can find the step by step instructions to use the SharePoint 2010 Client Object Model here)
Error Message:
'Form' is an ambiguous reference between 'System.Windows.Forms.Form' and 'Microsoft.SharePoint.Client.Form'
Reason: The reason is obvious and we can get from the error message itself. Yes, after added the SharePoint Client reference to the code, there is a conflict between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’! Initially our Form1 class inherits from Form class (by default System.Windows.Forms.Form) and currently our program confuses to choose the correct reference.
Solution: Provide full reference to the Form class will be the solution for this issue, so replace ‘Form‘ with ‘System.Windows.Forms.Form‘
After Replacing the code:
public partial class Form1 : System.Windows.Forms.Form { public Form1() { InitializeComponent(); } }
That’s all guys, Happy Programming with Client Object Model.
Thanks, R../
The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?) – SharePoint 2010 Client Object Model dlls
Posted by Rajanihanth in .Net, Client Object model, SharePoint 2010 on July 13, 2012
When I started using the Client Object model (Client OM) in SharePoint 2010, I have got this simple error and I just want to share with you in this blog. Following was my develpment environment.
- Windows 7, 64 bit
- Console Application Visual Studio 2010
- Added Client Object Model references (Microsoft.SharePoint.Client.dll & Microsoft.SharePoint.Client.Runtime.dll) to the solution
After setting up all the above, I was trying to add the client reference to the code ‘using Microsoft.SharePoint.Client;‘and then I have got the following error and warnings 🙂
The text format of error is:
"The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"
It’s an obvious error message and the reason of this error is:
SharePoint 2010 does not support .Net 4.0 in default and Visual Studio 2010 default framework is .Net 4.0.
Here are the simple steps to fix this:
Step 1: Right click on the project –> Properties
Step 2: Change the Target framework –> .Net Framework 3.5
Step 3: Warning message will be popping up, click Yes.
That’s all. Happy Coding..!
Please Note: If you use Windows Application then you will be getting an other error message! 😦 To solve this issue just click here.
This workbook cannot be opened because it is not stored in an Excel Services Application trusted location – SharePoint 2010
Posted by Rajanihanth in Excel Services, SharePoint 2010 on June 28, 2012
One of my colleagues sent me an email saying that he is getting this error (see below) whenever he tried to open an excel workbook. I just clicked the same file in the same location and I am able to open it. 🙂
But when I click on the excel file drop down –> View in Browser then I also got the same error.
The text format of the error is:
This workbook cannot be opened because it is not stored in an Excel Services Application trusted location. To create an Excel Services Application trusted location, contact your system administrator.
According to the error message, obviously we need to add the document library path to Trusted File Locations in the Central Administration. So we will see the steps here.
Step 1: Go to Central Administration –> Manage service applications under Application Management
Step 2: Then click on the Excel Services Application
Step 3: Click on the Trusted File Locations
Step 4: Just click Add Trusted File Location under Excel Services Application
Step 5: Add the document library url (OR file location) on the Address box and check the Children trusted check box –> Click ok
Please note: Don’t use like http://server:1010/documentlibrary1/forms/default.aspx instead of http://server:1010/documentlibrary1
If you use SSL (Secure Sockets Layer)/HTTPS connections, just add https:// on the address.
If you want to read more about this just click here. The similar problem in SharePoint 2007 also, you can find the solution in my previous post.
After completing this configuration, you might get the “The workbook cannot be opened” error, if you want to get the solution just read here. 🙂
References:
1. http://sharepointknowledgebase.blogspot.ca/2011/12/excel-services-sharepoint-2010-trusted.html
Access is denied: ‘xxx.dll’ – Manually add an assembly (.dll) to the GAC on Windows Server 2008 R2
Posted by Rajanihanth in .Net, GAC, SharePoint 2007, SharePoint 2010, Webpart on June 26, 2012
I supposed to post this issue few months ago, but I don’t really know why this has been in my draft folder till this date! When we were migrating our servers to new environment, we deployed some custom web parts manually. While deploying the web part (Drag and drop the assembly (web part .dll) into Global Assembly Cache (GAC) folder) I have got the following wired error message! 😦
GAC normally located in C:\Windows\assembly directory, and ‘WebPartStepBiStep.dll‘ is my web part assembly.
After spending some time on the web, I have got the solution here. Actually the ‘User Account Control: run all administrators in Admin Approval Mode’ was Enabled on the Local Security Policy. Which means the local administrators group required Admin Approval Mode (AAM) to perform these kind of operations. Here is the definition for Admin Approval Mode (AAM) from MicroSoft site.
Admin Approval Mode: AAM is a User Account Control (UAC) configuration in which a split user access token is created for an administrator. When an administrator logs on to a Windows Server 2008, the administrator is assigned two separate access tokens. Without AAM, an administrator account receives only one access token, which grants that administrator access to all Windows resources.
To access the Local Security Policy, either we can goto the Administrative Tools –> Local Security Policy OR we can run the ‘secpol.msc’ on the command prompt.
Start –> Administrative Tools –> Local Security Policy
Click Start –> Cmd –> type ‘secpol.msc’ then enter
You will be getting the Local Security Policy window like below and the highlighted is the AAM.
So the solution for our problem is Disabled the User Account Control. To do this double click on the highlighted policy on the Local Security Policy above and then you will be getting this window.
Click Disabled and OK.
After disabling this you will be able to drag and drop the .dll to the GAC.
Please Note: 1. Rebooted required for changes to the local security policy on the server.
2. Disabling this can make security problems in your environment, so after completing task, you should be enabled back the UAC.
That’s all guys, Happy drag and dropping..!
Thanks. R/.
References:
Content Editor Web Part (CEWP) & JavaScript duplicating entries in SharePoint 2010
Posted by Rajanihanth in SharePoint 2007, SharePoint 2010, Webpart on June 19, 2012
Recently we have migrated our SharePoint 2007 application to SharePoint 2010 and we also had manually configured few web parts in the new environment. Most of the web parts were working perfectly like sharepoint 2007 but one content editor web part which shows the weather forecast had some wired repeating behavior! 😦
Here is the weather forecast web part in the 2007 which has JavaScript to update the weather from their web site.
The JavaScript code in the Source editor:
I have created the CEWP in 2010 and paste the source code in to the editor.
and Publish the page, It is working fine no? but not really..!
Whenever I edit the page, the web part is duplicating the weather widget like this!
After spending few minutes I have found the solution in this post, actually SharePoint 2010 does not support the JavaScript directly into the source editor. So we cannot copy and paste the JavaScript to the CEWP editor instead, we have to create the scripts as a txt file (paste into a Notepad and save), upload into the SharePoint and then pointing that file as the source of CEWP.
Step 1: Open a Notepad and paste the source code
Step 2: Upload the txt file into SharePoint
Step 3: Get the url path of the txt file and paste it on the content link property of the content editor pane on the right side and click ok.
That’s all. No duplication probs any more. Happy Migrating..!
Thanks. R./
References:
1. http://sharepointadam.com/2010/08/31/insert-javascript-into-a-content-editor-web-part-cewp/