If somebody like the post and its helpful in your work then, add comments.

Wednesday, December 1, 2010

STSADM on adding wsp Error “Object reference not set to an instance of an object. sample.wsp: The Solution installation failed. ”

Hi, Well today when I was deploying the SharePoint site I got the above error. Well on first look it seems that this is SPSite or SPWeb or we can say that this object model issue. But I got info from googling that this issue comes due to permission on the content db from which the user is deploying the WSP by using the STSADM command. Well I looking for more options for that but it seems that the issue is due to user permission on content db.

And guess it works. Well when you dont have permission on the Admin_content db then this issue will occur.

The below command will also help you check the permission

stsadm -o enumsites -url http://yoururl

Wednesday, October 6, 2010

SharePoint 2010: What is Sandbox Solution?

Well,

Many of the SharePoint are working on the SharePoint for a long time. Many of then also started working in the SharePoint 2010. Their are many things that SharePoint 2010 made easier then from SharePoint 2007/Moss. Many improvements are given to the SharePoint to that it can build a better solution.

If you have been reading about exciting new features of SharePoint 2010 you probably heard about something called SandBox Solutions.  What is the Sandbox solution?

SharePoint is a rich development platform with a large community actively developing solutions. The challenge, however, has always been the balance between creating solutions and deploying them in a way that you can trust will not damage or impair the SharePoint farm. Sandboxed solutions, new in SharePoint 2010, address this by allowing site collection administrators to deploy solutions that are safe to run. Sandboxed solutions are restricted to running under a subset of the SharePoint API and the framework can monitor these solutions and shut down any that risk the stability of the farm.

SandBox Solutions support the following SharePoint item types:

  • List definitions
  • List instances
  • Content Types/Fields
  • Navigation
  • Web Parts derived from WebPart
  • Event receivers
  • Custom Workflow Actions
  • Workflows

Development

For developing a sandbox solution you have to just create a new blank SharePoint Solution in Visual Studio 2010. Go to properties of the solution and change the solution type to true.

SanJuan013 

Deploying Sandboxed Solutions

The structure of a sandboxed solution is very similar to a farm solution, which generally runs with full-trust permissions. The main differences lie in how a sandboxed solution is deployed and in the process that hosts the solution (which determines whether a solution is a sandboxed solution or a farm solution). This means that the same sandboxed solution can run with full trust when it’s deployed at the farm level and with partial trust when it’s deployed at the site collection level.

SanJuan014

Monday, September 6, 2010

SharePoint 2010 : Paging in the SharePoint list

Hi,

Paging in the SharePoint 2010 list is done using the

SPListItemCollectionPosition 

The SPListItemCollectionPosition class supports paging through data sets, storing the state that is needed to get the next page of data for a specific view of a list.

ListItemCollectionPosition

Gets or sets an object that is used to obtain the next set of rows in a paged view of a list. The below code I have refined from the following link. It will return the given page like page 3, items say 4.



public static SPListItemCollection ExecuteCAMLToRetrieveListItemsInPages( string listName, string viewName, 
string caml, string[] columnNames, int pageIndex, int pageItemCount)
{
SPListItemCollection postDetailsItems = null;
using (SPSite Site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb sharePointWeb = Site.AllWebs[XYZ])
{
// Check if the SharePoint web object is not null or not.
if (sharePointWeb == null)
{
}
// Get the Post List
SPList postList = sharePointWeb.Lists[listName];
// Get the SPLIst View
SPView listView = postList.Views[viewName];
SPQuery query = new SPQuery(listView);
query.Query = caml;
// Retrieve the items for the last page. E.g.: If request is for 5th page and item count/page=10 then row limit will retrieve
//40 items and 40th item will be used to get the column details which will be used for pagination.
query.RowLimit = (uint)(pageItemCount * (pageIndex - 1));
postDetailsItems = postList.GetItems(query);
// Get the previous page last item position. Use this item to retrieve the column details which will be used for pagination.
int previousPageLastItemPosition = postDetailsItems.Count - 1;
StringBuilder columnBuilder = new StringBuilder();
// Form the paging filter query string
if (columnNames != null)
{
foreach (string column in columnNames)
{
// Make sure that if the field value is mandatory and if you are passing it as NULL then SPList.GetItems will throw exception.
string columnValue =
(postDetailsItems[previousPageLastItemPosition][column] == null) ? string.Empty : postDetailsItems[previousPageLastItemPosition][column].ToString();
// Check if the value is null or empty
columnBuilder.Append("&p_" + column + "=" + columnValue);
}
}
query = new SPQuery(listView);
query.Query = caml;
// Create Paging Information which will be used for retrieving paging based items
SPListItemCollectionPosition objSPListColPos = new SPListItemCollectionPosition("Paged=TRUE" + columnBuilder.ToString());
query.RowLimit = uint.Parse(pageItemCount.ToString());
query.ListItemCollectionPosition = objSPListColPos;
// Execute the CAML query.
postDetailsItems = postList.GetItems(query);
}
} return postDetailsItems;
}

Wednesday, August 25, 2010

SharePoint Database when set to status ‘Suspect’

Hi,

Today my SharePoint 2010 Admin database automatically set to status Suspect.

SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454(Suspect)

I search for that issue and I got the solution which is below

EXEC sp_resetstatus 'SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454'

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET EMERGENCY

DBCC checkdb('SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454')

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

DBCC CheckDB ('SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454', REPAIR_ALLOW_DATA_LOSS)

ALTER DATABASE [SharePoint_AdminContent_c92d3a99-1800-4cac-b986-7e380ea42454] SET MULTI_USER

Thursday, August 19, 2010

SharePoint Web Part Development

Hi again,

Now these days I am working for the SharePoint 2010 internet facing or public facing publishing site. No doubt's we are using the OOTB publishing features of the SharePoint 2010 publishing, content types, approval workflows etc.

Well, in that site I am developing the custom web parts for the site in the Visual Studio 2010 version 10.0.30319.1 RTMRel. In this or before VS 2010 we have the .net framework 3.0 in which HtmlGenericControl which is present in the System.Web.UI.HtmlControls namespace. It will help us to build the custom UI for the web part instead of maintaining HTML in the web part and render to output(HTMLTextWriter).

You can create any of the HTML tag from HtmlGenericControl this like div, table, table row, table column and that will be very easy to manage in the code.

How this will work ?

In the code we have to add reference for the control and declare the HtmlGenericControl control in the class like :

HtmlGenericControl divSponser_Blogs_Contatiner;
In the CreateChildControl or any method where you are creating the UI for the web part you can instantiate it.

divSponser_Blogs_Contatiner = new HtmlGenericControl("div");
You can also set its properties like CSS class or its attributes in the control after instantiate.

divSponser_Blogs_Contatiner.Attributes.Add("class", "Sponser-Blogs-Contatiner");

or like

divSponser_Blogs_Contatiner.Attributes.Add("id", "Sponser_Blogs_Contatiner");
if you wnat to create table from HtmlGenericControl then you have to just replace div with table.

divSponser_Blogs_Contatiner = new HtmlGenericControl("table");
Well this post will help you to create rich UI web parts for the SharePoint and it will also make easy to mage and create the custom web parts from the .net framework.

Friday, July 23, 2010

SharePoint 2010 : Custom Membership and Role providers

 

Hi all,

Now these day I was busy with some SharePoint 2010 project. One of my project I have to configure Form Based authentication for the site. In this configuration we didn't use the default Asp.Net providers for authentication.

“ASP.NET membership is designed to enable you to easily use a number of different membership providers for your ASP.NET applications. You can use the supplied membership providers that are included with the .NET Framework, or you can implement your own providers.”

So I have create or we can implemented the custom provider class with custom SQL database and tables. We have inherited the asp.net abstract classes “MembershipProvider” and “RoleProvider”  in our custom classes. The project is class library project for creating DLL, e have to used for installing in GAC.

This Membership Provider class have following following structure:

Variables

        private int newPasswordLength = 8;
        private string connectionString;
        private string applicationName;
        private bool enablePasswordReset;
        private bool enablePasswordRetrieval;
        private bool requiresQuestionAndAnswer;
        private bool requiresUniqueEmail;
        private int maxInvalidPasswordAttempts;  private int passwordAttemptWindow;
        private MembershipPasswordFormat passwordFormat;
        private int minRequiredNonAlphanumericCharacters;
        private int minRequiredPasswordLength;
        private string passwordStrengthRegularExpression;
        private MachineKeySection machineKey; //for encryption

Properties

VISIOITPro000

Method which I have implemented:

VISIOITPro002

And the methods which I have not Implemented:)

VISIOITPro001

Their are some other helper methods also there like encryption for password. Similarly I have implemented role providers. Well you can get both the classes from here.

Some more configuration you have to make for the SharePoint 2010 FBA like STS, Central Admin and your port 80(primary web app) application.  I have manually manipulated all web.config files of application and they are working.

Enjoy :)

Thursday, May 20, 2010

Forms Authentication in SharePoint 2007

SharePoint 2007 and MOSS 2007 are built on ASP.Net 2.0 which means they can leverage many of the same features of ASP.Net 2.0 including the AspNetSqlMembershipProvider for use with Forms Based Authentication. There are great guides to configuing FBA: Andrew Connell had the best article first.

Patches in the Configuration of FBA.

1. Creating Two Web Applications on same port

When we Creating Two Web Applications, One For Each Authentication Mechanism on same port(As 80) then you have to add host headers from which the application will be browsed. But the when you create the web application with host headers(as extranet or internet) then the URL does not resolved. It will does not display your site. To resolve this you have add DNS entry for that and also configure AAM for the same.

VISIOITPro000



VISIOITPro001

Alternate Access Mapping

VISIOITPro002

2. Login prompt for site collection

When we create site collection and above all settings done, then it prompts for the login. But after giving credentials it again and again prompts for the credentials and we cannot browse over site.

After goggling on this issue I have found solution of this issue at one link.

In order to fix this authentication prompt issue on any machine, disable the loopbackcheck on the server. Its a issue with IE due to security update. Please follow below steps to disable loopbackcheck:
  1. Click Start, click Run, type regedit, and then click OK.
  2. In Registry Editor, locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
  3. Right-click Lsa, point to New, and then click DWORD Value.
  4. Type DisableLoopbackCheck, and then press ENTER.
  5. Right-click DisableLoopbackCheck, and then click Modify.
  6. In the Value data box, type 1, and then click OK.

At above all the configuration steps I think It would help you in configuring FBA on SharePoint 2007.

Thursday, March 11, 2010

SharePoint 2007 : Create Custom List Action entry and attach the dll to it.

Create a new SharePoint empty project. Create a hierarchy in that like below.

VISIOITPro024

Element.XMl



Code Snippet



  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  3.   <CustomAction
  4.     Id="{B08087EF-B682-4fb4-870B-A7CC3F1FDF0B}"
  5.     Title="Slide Reorder"
  6.     RegistrationType="List"
  7.     GroupId="ActionsMenu"
  8.     Location="Microsoft.SharePoint.StandardMenu"
  9.     Sequence="1000"
  10.   RegistrationId="2100"
  11.     Rights="EditListItems"
  12.     ControlAssembly="GMISlideLibraryFeature,Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"
  13.     ControlClass="GMISlideLibraryFeature.SlideReorderAction">
  14.   </CustomAction>
  15. </Elements>






Code Snippet



  1. class SlideReorderAction : WebControl
  2.     {
  3.         private MenuItemTemplate _MenuTemplate;
  4.         protected override  void OnLoad(EventArgs e)
  5.         {
  6.             EnsureChildControls();
  7.             base.OnLoad(e);
  8.         }
  9.         protected override void CreateChildControls()
  10.         {
  11.             base.CreateChildControls();
  12.             ListViewWebPart oListView = FindListView(Parent);
  13.             if (oListView == null) return;
  14.             {
  15.                 SPWeb site = SPContext.Current.Web;
  16.                 site.AllowUnsafeUpdates = true;
  17.               
  18.                 _MenuTemplate = new MenuItemTemplate
  19.                 {
  20.                     Text = "Slide Reorder",
  21.                     Description = "This feature allows Site Owners to add a Change Order menu item to the Slide Library",
  22.                     ImageUrl = "/_layouts/images/NEWITEM.GIF",
  23.                     ClientOnClickNavigateUrl = "javascript:window.location= '" + site.Url + "/_layouts/GMISlideReorder/SlideReorder.aspx?List=" + oListView.ListName + "&Source=' + window.location"
  24.                 };
  25.                 this.Controls.Add(_MenuTemplate);
  26.             }
  27.         }
  28.         private ListViewWebPart FindListView(Control oParent)
  29.         {
  30.             if (oParent is ListViewWebPart) return (ListViewWebPart)oParent;
  31.             if (oParent.Parent == null) return null;
  32.             return FindListView(oParent.Parent);
  33.         }
  34.     \




VB.NET : SharePoint Solution Template in Visual Studio

When we create a solution for SharePoint(like a feature) then when we use SharePoint Empty project template in visual studio 2008 then it creates a default namespace VeWSE instead of the solution name.

VISIOITPro017

default namespace

VISIOITPro019

So, when we activate feature or inherit another class in that then we have get the error “systemexceptionempty”. Because we provide

ControlAssembly="CustomActionControlClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abf59b3ca9443f64"
ControlClass="CustomActionControlClass.MyCustomAction"
in element.xml file. And the actual namespace is VeWSE.Namespace.ClassName.


VISIOITPro023



Workaround



Delete the default namespace from that project properties.