Showing posts with label MOSS. Show all posts
Showing posts with label MOSS. Show all posts

Create an Event Handler Feature with VSeWSS1.3

Posted by Kasi Krishnamoorthy at 10/06/2009 01:13:00 PM

How to: Create an Event Handler Feature with VSeWSS1.3

Prerequisites:

Read the following to understand about Event model and Feature in SharePoint.

· Event Fundamentals

· Working with Features

· Solutions Overview

Software Environment:

· VM with MOSS 2007 SP2

· Visual Studio 2008 Professional

· VSeWss 1.3

Object Model:

SharePoint Object Model exposes several event classes inherited from Microsoft.SharePoint assembly. There are four important classes:

· SPItemEventReceiver Class

· SPListEventReceiver Class

· SPWebEventReceiver Class

· SPFeatureReceiver Class

Building the Feature:

It shows how to add a simple event handler that prevents items from being added to a list. Two procedures are involved in this task:

· Creating an event handler in Microsoft Visual Studio

· Adding the event handler as a Feature in Windows SharePoint Services

1. Create a new project in Visual Studio by clicking File, pointing to New, and then clicking Project.

clip_image002

Select Empty project from the SharePoint template list and give a name to the project

2. Select GAC from the Trust Level ( Event Handlers must be deployed only in GAC)

clip_image004

3. In Solution explorer, Right click on the project, and Add a new Item to the project

clip_image006

Select SharePoint category and select the ‘event receiver’ template.

clip_image008

Select ‘Document Library’ from the list

clip_image010

4. This would have created set of files for ItemEventReceiver and ListEventReceiver, as shown below. Depending on the situation you can delete either one of the EventReceiver.

clip_image012

5. Open the ItemEventReceiver.cs file and add code to the ItemAdding event as shown below. The code will prevent adding new item to the list.

clip_image014

6. Similarly add code to the ListEventReceiver as shown below. The sample code will prevent adding new column to the list.

clip_image016

7. Select Project Properties and enter the URL location of website where you want to deploy the EventReceiver.

clip_image018

8. Next step is to create solution to deploy these two Features. Click on ‘WSP View’ (or press Ctrl+W,I), you can see list of files required for the Solution with two Features.

clip_image020

9. Open the ‘feature.xml’ under ItemEventReceiver and change the title to meaningful one. If required add ‘Description’ also.

clip_image022

10. DO the same for the other Event receiver.

11. Press F5 to compile and deploy the solution. Also this would create a WSP file under bin/debug directory. You can use this WSP file to deploy this in different website.

12. Go to SharePoint website, SiteActions->Site Settings->Site Feature and check that the two Features are deployed and activated properly.

clip_image024

clip_image026

13. Open the Document Library within the website and try to add an Item / a column. This should generate a custom error like this.

clip_image028

Microsoft’s SharePoint Thrives in the Recession

Posted by Kasi Krishnamoorthy at 8/10/2009 12:54:00 PM

 

Hang around at Microsoft’s Redmond, Wash., headquarters for five or ten minutes and someone dressed in khaki pants and a blue shirt is bound to tell you about the wonders of SharePoint — one of the company’s most successful and increasingly controversial lines of software. Think of SharePoint as the jack-of-all-trades in the business software realm. Companies use it to create Web sites and then manage content for those sites. It can help workers collaborate on projects and documents. And it has a variety of corporate search and business intelligence tools too. To read more, click here…

http://bits.blogs.nytimes.com/2009/08/07/microsofts-sharepoint-thrives-in-the-recession/

Prevent making changes to WSS content types.

Posted by Kasi Krishnamoorthy at 7/09/2009 03:20:00 PM

 

There are three ways you can prevent users from making changes to SharePoint (WSS) content types. Also there are few things to consider before taking these steps.

1: Read-Only content types:

You can set it read-only using the interface, like this..

image

But once you set it read-only, then:

  • You cannot make changes to the content type thro WSS interface.
  • YOU CAN only make Changes programmatically using object model.
  • Pushing down parent content type changes (if any) is little tricky.

2. Sealed Content Type.

This provides more control, but a content type can only be made sealed type by editing the XML definition of the content type.

But once you set it sealed, then:

  • You cannot make changes to the content type thro WSS interface.
  • You cannot make changes programmatically using object model.
  • Pushing down parent content type changes to the sealed content type is not possible.

3. Hidden type.

You can assign a content type to a predefined group called, “_Hidden” (case sensitive). You can set it as shown below..

image

But once you set it to hidden group, then:

  • Hidden types are not visible, so you cannot make changes to the content type thro WSS interface.
  • You can make changes programmatically using object model ( including inheriting).
  • Pushing down parent content type changes to the child content type is possible.

For hidden , see here for more information. Content Type Access Control

Hope it helps.

Deleting content type…

Posted by Kasi Krishnamoorthy at 7/08/2009 10:30:00 AM

In SharePoint 3.0, Can you delete a content type, if it is being used in other site or list ? No, you cannot. We know that we can create a content type based on other content type and each content type contains reference to the content type on which it is based on. SharePoint checks that before deleting a content type whether it is being used somewhere as a base of content type. You have to remove first the content type from all lists and sites that are using it.   But, the good thing is , WSS won’t consider the items ( that are using the deleted content type) in the recycle bin. So when you try to restore the list item after their content type has been deleted, the list items are assigned to default content type ( instead of giving strange error like “content type not found”.)

 

 

Could not able to uninstall SharePoint

Posted by Kasi Krishnamoorthy at 4/23/2009 02:21:00 PM

Configuration:

MOSS (2007 with SP1) installation on windows 2003 R2 (SP2) standalone machine. (Contains WFE, Appserver, and SQLDB with Embedded Edition)

 

Reason for crash:

The latest change in Auto update configuration of the machine, automatically updated the SQL server with SP2. This machine contains only MS embedded edition (which comes with basic installation of MOSS) of SQL server, not standard or higher. I think the SP2 is not for EE, and obviously corrupted the config DB.

 

Detail:

After the latest MS patch, the MOSS server stopped working. It gave couple of error like this in the event viewer.

· Unknown SQL Exception 33002 occurred. Additional error information from SQL Server is included below.

Access to module dbo.proc_GetCurrent is blocked because the signature is not valid.

· The description for Event ID ( 33002 ) in Source ( MSSQL$MICROSOFT##SSEE ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: module, dbo.proc_GetRunnableWorkItems.

· Cannot start service SPAdmin on computer…. (part of configuration wizard rerun process).

 

Explored Solution:

1. Ran the SharePoint configuration wizard did not help. It stopped at the 4 or 5th point.

2. Server reboot did not give any help. Tried configuration wizard again….no luck.

3. Tried to upgrade the DB with the following command. %commonprogramfiles%\Microsoft Shared\Web Server Extensions\12\BIN\psconfig -cmd upgrade -inplace b2b -wait -force

4. So tried to remove the MOSS installation, Using Add/Remove programs. But I could not able to uninstall SharePoint trial version. The uninstall option quit without any error.

5. Ran the MOSS installation program(using installation CD) and chose the ‘remove’ option to remove the existing MOSS installation. This also did not work (program stopped without any error).

6. Finally I reinstalled the latest service pack, SP1, again on WSS and MOSS. Then I ran the configuration wizard, which went through without any error. The SharePoint sites started working (no errors in the log).

 

Strange... but worked..

Two DB with Standalone installation of SharePoint

Posted by Kasi Krishnamoorthy at 4/23/2009 01:58:00 PM

 

When I installed SharePoint on a standalone machine, it installed two different installation of SQL server

1. One is Embedded edition which stored the site content.  This database is located in Windows directory.  This one is running with service name of Microsoft##SSEE.

image

To connect to this use this as server name in SQL management studio:\\.\pipe\MSSQL$Microsoft##SSEE\SQL\query

 

2. The second installation for Search content and the location of the content DB is within 12 hives. This one is running with service name of OFFICESERVERS.

 

image

 

I am just wondering why do we need two instances of SQL server? We could have achieved with one SQL server instance. Any Idea?