Monday, June 25, 2012

Adding DLL to WSP SharePoint 2010

In order to add custom dll to WSP Package , follow these steps:

  • Create new Empty SharePoint Project 
    • File->New->Project->SharePoint(2010)->Empty SharePoint Project 
    • In second screen provide test site URL
    • Select "Deploy as Farm Solution"

  • Expand package node and double click on Package.package file 




  • Click on "Advanced" Tab



  • Add the Custom dll's using the "Add" button



  • Save the project, compile and deploy. Custom dll will be part of WSP.

Enjoy!!!!

Rags

Wednesday, June 13, 2012

SharePoint Foundation 2010 Best Practice

Sandbox Solution Capabilities

Complete Article :http://msdn.microsoft.com/en-us/library/ee231562.aspx

In Nutshell


Sandboxed solutions support the following capabilities and elements:

Content Types/Fields

Custom actions

Declarative workflows

Event receivers

Feature callouts

List Definitions

List Instances

Module/files

Navigation

Onet.xml

SPItemEventReceiver

SPListEventReceiver

SPWebEventReceiver

Support for all Web Parts that derive from System.Web.UI.WebControls.WebParts.WebPart

Web Parts

WebTemplate feature elements (instead of Webtemp.xml)

Visual Web Parts

Sandboxed solutions do not support the following capabilities and elements:

Application Pages

Custom Action Group

Farm-scoped features

HideCustomAction element

Web Application-scoped features

Workflows with code



Monday, June 11, 2012

Get Machine Name and IP ASP.NET

My previous post has an function which is now deprecated.
http://metahat.blogspot.com/2009/09/get-client-machine-name-aspnet.html
System.Net.Dns.GetHostByAddress(Request.UserHostAddress).HostName


Following are the new function to get client machine name and IP address:

string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' });
                        
string machineName=computer_name[0].ToString();
string ipAddress  =Request.ServerVariables["REMOTE_ADDR"].ToString();

Wednesday, June 06, 2012

Powershell Commands (Mostly Used)

Here is collection of commonly used powershell cmdlets.
More details :
http://technet.microsoft.com/en-us/library/ee906565.aspx

Add-SPSolution(Uploads a SharePoint solution package to the farm.)
Add-SPSolution -LiteralPath c:\contoso_solution.wsp

Remove-SPSolution(Removes a SharePoint solution from a farm.)
Remove-SPSolution -Identity contoso_solution.wsp

Install-SPSolution(Deploys an installed SharePoint solution in the farm.)
Install-SPSolution -Identity contoso_solution.wsp -GACDeployment

Uninstall-SPFeature(Uninstalls an installed feature definition.)
Uninstall-SPFeature -path "MyCustomFeature"

Add-SPUserSolution(Uploads a new sandboxed solution to the solution gallery.)
Add-SPUserSolution -LiteralPath c:\contoso_solution.wsp -Site http://sitename

Disable-SPFeature(Disables an installed SharePoint Feature at a given scope.)
Disable-SPFeature –identity "MyCustom" -URL http://somesite

Enable-SPFeature(Enables an installed SharePoint Feature at the given scope.)
Enable-SPFeature –identity "MyCustom" -URL http://somesite

Get-SPFeature(Returns the SharePoint Features based on a given scope)
Get-SPSite http://somesite | Get-SPWeb –Limit ALL |%{ Get-SPFeature –Web $_ } | Select DisplayName,ID -Unique

Install-SPFeature(Installs a SharePoint Feature by using the Feature.xml file.)
Install-SPFeature -path "MyCustomFeature"

Uninstall-SPFeature(Uninstalls an installed feature definition)
Uninstall-SPFeature -path "MyCustomFeature"


 

SharePoint 2010 101 Code Samples

Monday, June 04, 2012

Error while Installing SharePoint Foundation 2010 to Win 7 Desktop

Error:
Setup is unable to proceed due to following error(s):
This product required Windows Server 2008 Service pack 2 or above.
Correct the issue(s) listed above and re-run set up.

Solution:
In Order to install SharePoint 2010 Foundation/Office Server 2010, you need to make changes to configuration settings.

Refer article below:
http://msdn.microsoft.com/en-us/library/ee554869.aspx

-Rags

Friday, June 01, 2012

Deploying SharePoint 2010 Package using VS 2010

Well today i created a solution package and tried to deploy it to SharePoint 2010 portal hosted in separate server.Though it sounds such a straight forward step, i managed to get a nice long error message stating :


Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site. Make sure that this is a valid URL and the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project

So i was back to my favorite page "google.com". (Not sure what would have been life of a techi if search engines would not had been there ;-) .)

So i came to know that currently Visual Studio 2010 only supports deployment of packages to locally installed SharePoint instance.So no remote support yet.

if you want to deploy to remote server than there are multiple ways to achieve this one :
http://msdn.microsoft.com/en-us/library/aa544500(office.14).aspx



Error while deploying package using Visual Studio 2010 to SharePoint 2010

Errors
Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again.

OR


Error occurred in deployment step 'Recycle IIS Application Pool': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.


Reason

The error pops up when userid doesn't have access to configuration and content DB.

Resolution
There are 2 ways to resolving this issue.

Preferable Method(1st method): 
Use Power shell command to provide user id access to SharePoint DB's.

  • "Add-SPShellAdmin -UserName domain\username" This will add permissions to the config database in SharePoint 2010
  • "Get-SPContentDatabase -WebApplication " This will return information on the content database for the desired web application
  • "Add-SPShellAdmin -UserName domain\username -database " This will add permissions to the content database for the desired web application



2nd method:
Add the userid as DBOwner to Configuration and Content DB. Though this is not best practice but will at least get you going.

-Rags




Gray Failures: What is it and how to detect one?

If you are reading this article , i guess you are curious to know about gray failures and different methods to detect gray failures.  Hopefu...