Archive for category Webpart
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/
There are no Business Data Types loaded in the Catalog – Business Data Type Picker
Posted by Rajanihanth in BDC, SharePoint 2007, Webpart on June 7, 2012
I was working on BDC (Business Data Catalog), to display the user profile data from SQL Server in SharePoint 2007. I was using “Application Definition Designer” (A Microsoft tool that comes with the SharePoint Server SDK, you can see the installation and configuration here) to generate the ADF (Application Definition File). I tried to access the Business Data Types on the SharePoint page and then I have got the following wired error message. 🙂
BDC is not a really new stuff, so I tried to find the solution on the web but I didn’t get any direct solution immediately. Most of them are suggested to check the permission but I have adequate permission for BDC. Finally I have got the solution form this thread. Actually this is a bug in the Application Definition Designer and I don’t really know why it’s still there!
There might be two reasons to getting this error.
1. Not having enough permission to access the BDC
2. The “Finder” method is not generating properly in the “MethodInstanceType” property.
In my case I had adequate permisioion for the BDC, so the “Finder” method was my problem.
You can see the “MethodInstanceType” property has “IdEnumerator” method instead of the “Finder”. So just click the drop down list and select the Finder method.
Then just export the ADF again, the Business Data Type Picker is showing the entries now huh? 🙂
References:
Deploy and Re-deploy a web part solution package (.wsp) using STSADM command.
Posted by Rajanihanth in SharePoint 2007, STSADM, Webpart, WSP Builder on June 4, 2012
Deploying a web part solution to the SharePoint using STSADM is an easy task, everyone knows about it. But while developing a web part, sometimes we need to re-deploy the solution again and again. In this case we cannot simply re-deploy the solutions and we have to follow some additional steps to redeploy again.
There are several ways to create the solution file, but I have used the WSPBuilder to create this web part solution. You can see this in my previous post.
Deploy :
There are 2 steps to deploy a solution using stsadm.
- Add solution – Add a solution file to the solution store. See more details here.
- Syntax: stsadm -o addsolution -filename <solution file name>
- Deploy solution – Deploys files related to a solution from the configuration database to individual front-end Web servers in the farm. See more details here.
- Syntax: stsadm -o deploysolution -name <solution name> -immediate -allowgacdeployment -force –allcontenturls
- We need one more command to Executes all administrative timer jobs immediately instead of waiting for the timer job to run. See more details here.
- Syntax:stsadm -o execadmsvcjobs
Ok, we will see the steps here:
Step 1: Open the cmd prompt and change the directory (cd) to stsadm.exe location, I am using SharePoint 2007 so this is the path: “cd c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin”
Step 2: Adding the solution, my solution file is in the C:\Temp\
stsadm -o addsolution -filename C:\Temp\WSPBuilderStepBiStep.wsp
Step 3: Deploying the solution
stsadm -o deploysolution -name WSPBuilderStepBiStep.wsp -immediate -allowGacDeployment -force -allcontenturls
Step 4: Executing the timer jobs
stsadm -o execadmsvcjobs
Please note: The name and filename in the above commands, if it is filename we have to use full file path.
Re-Deploy:
When we deploy the solution package without retract and delete then we will get the following error message:
There are many ways to do this (Using UI, WSPBuilder and so…) but here are the steps which I normally used (Specially in the production servers):
- Retract solution: Retracts the specified solution’s deployment which removes files from the front-end Web server. This is actually reversing the deployment. See more details here.
- Syntax: stsadm -o retractsolution -name <solution name> [-immediate] [-allcontenturls]
- Delete solution:Removes a solution file (package) from the solution store. See more details here.
- Syntax: stsadm -o deletesolution -name <name> [-override]
Here are the steps:
Step 1: Retracting the solution
stsadm -o retractsolution -name WSPBuilderStepBiStep.wsp -immediate –allcontenturls
Step 2: Executing the timer jobs
stsadm -o execadmsvcjobs
Step 3: Deleting the solution
stsadm -o deletesolution -name WSPBuilderStepBiStep.wsp –override
Step 4: Re-deploy the solution again, for this follow the steps 1 to 3 in the Deploy!
That’s all, Happy deploying..! 🙂
Developing a simple web part (.wsp) using WSPBuilder
Posted by Rajanihanth in SharePoint 2007, Webpart, WSP Builder on May 28, 2012
Before we started the development, we have to install the WSPBuilder (SharePoint WSP tool), an extensions for Visual Studio. Just download the latest version here and install it. It is pretty easy steps.
Step 1: Create a new project on visual studio and then select the project type WSPBuilder under C# programming language (I am using Visual Studio 2008).
Step 2: This is will create the following structure in the solution explorer.
Step 3: Right click on the project (WSPBuilderStepBiStep) and then add a new Item.
Step 4: This will give the following dialog box and then select WSPbuilder and Web Part Feature template. Enter the name and click Add button (I have given WebPartStepBiStep here)
Step 5: We will get the following dialog box and asking for the scope for this Web Part. I just modified the description and select the scope and then click OK.
Step 6: The solution explorer will look like this. Under the 12 hive folder you can see the Template and Features sub folders.
Step 7: Double click on the WebPartStepBiStep.cs file and add your custom code on the right place. I just modifed the property like this:
public string MyProperty { get { if (_myProperty == null) { _myProperty = "Hello Step Bi Step!"; } return _myProperty; } set { _myProperty = value; } }
If you wanna to add a label rather than using this LiteralControl just replace the following code
this.Controls.Add(new LiteralControl(this.MyProperty));
with this
System.Web.UI.WebControls.Label label=new System.Web.UI.WebControls.Label(); label.Text = "Hello StepBiStep!"; this.Controls.Add(label);
Step 8: After replacing the code, the CreateChildControls() method will look like this:
protected override void CreateChildControls() { if (!_error) { try { base.CreateChildControls(); // Your code here... System.Web.UI.WebControls.Label label=new System.Web.UI.WebControls.Label(); label.Text = "Hello StepBiStep!"; this.Controls.Add(label); } catch (Exception ex) { HandleException(ex); } } }
Step 9: To build the project, just right click on the project name (WSPBuilderStepBiStep –> Build) and click Build.
Step 10: To build the WSP, Right click on the project name(WSPBuilderStepBiStep) –> WSPBuilder –> Build WSP
Step 11: This will create the .dll and .wsp files.
Step 12: To deploy the web part (.wsp file), right click on the project name(WSPBuilderStepBiStep) –> WSPBuilder –> Deploy
Step 13: You will get the following output, saying the .wsp file deployed successfully (done!).
Step 14: Go to the Web Part gallery and populate the deployed Web Part on the New web part page.
Step 15: To use this Web Part in to your page, just follow these steps from my previous post. That’s all! Happy WSPBuilding..! 🙂
Please note: You have to run the Visual Studio as Administrator, otherwise you will get this error when you deploy the web part.
References:
1. http://rasor.wordpress.com/2008/10/12/wss-dev-quickstart/
How to add a custom web part to SharePoint 2007
Posted by Rajanihanth in SharePoint 2007, STSADM, Webpart, WSP Builder on May 25, 2012
Everyone knows about this, but I wanted to re-use this for my next series of custom web part posts. 🙂
I have already developed and deployed the web part (WebpartStepBiStep.wsp) using STSADM command, you can see my previous post here. Now we will see the steps:
Step 1: On the SharePoint site, click Site Actions –> Site Settings –>Modify all site settings
Step 2: Site Settings page, click Web Parts under Galleries
Step 3: On the Web Part Gallery page, click New
Step 4:On the New Web Parts page, select the check box next to the Web Part that you want to add, and then click Populate Gallery
Step 5: Web part will be showing on the web part gallery.
Step 6: Click Site Actions, and then click Edit Page
Step 7: Click Add a Web Part
Step 8: In the Add Web Parts dialog box, select the check box next to the Web Part that you want to add, and then click Add button
Step 9: The web part will be shown on your page.
Step 10: If you want modify the appearance and layout then Click Publish.
Step 11: That’s all, we are done.
Reference:
http://support.microsoft.com/kb/939306
How to remove a corrupted WebPart from a page in SharePoint 2007
Posted by Rajanihanth in SharePoint 2007, Webpart on March 10, 2012
When I was playing with custom WebParts in SharePoint 2007, I used to getting an error message saying “An unexpected error has occurred“ and I could not navigate to the previous page again! Because SharePoint stores all the .aspx pages directly to the database, so when a corrupted WebPart added to the page we cannot access them!
Add a custom WebPart to the SharePoint page:
Unexpected error:
So you need to delete this corrupted WebPart to navigate to the page again. There might be several way to solve this issue, but following is an easy way to delete the WebPart! Here you go 🙂
Step 1: Just type “?contents=1” in the address bar to the end of the url and Press <Enter>.
You will be navigating to the following Web Part Page Maintenance page.
Step 2: Select the WebPart which you want to delete (OR whatever you want to do) and click delete link button on the top. That’s all you are able to navigate to the page without any issue!
Please note: If you change any other WebPart in the Web Part Page Maintenance page, it will be affecting all other users who have access this page!
R./
References:
1. http://erichanes2008.blogspot.com/2011/10/remove-corrupted-web-parts-in.html
WSP Builder Error 1 – Microsoft SharePoint Services Timer is not running on ”Server Name”
Posted by Rajanihanth in SharePoint 2007, Webpart, WSP Builder on March 7, 2012
I was developing a Webpart using WSPBuilder (SharePoint WSP tool) in my new development server (SharePoint 2007, Visual Studio 2008 and Windows 2008 R2) and was trying to deploy the solution then I have got the following error message!
I have checked the “Windows SharePoint Services Timer” on the Windows Services and it was running! I tried to re-build and re-deploy the solution again and I have got the same error message again. 😦
Start –> Administrative Tools –> Services
After spending several minutes and I have found the solution here!
If we want to deploy a solution using WSPBuilder, it needs the Administrative privileges, so we need to run the Visual Studio as Administrator.
That’s it, I was able to deploy the Webpart successfully!
References: