MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

MOSS 2007 EventHandler

  Asked By: Dejuan    Date: Jan 08    Category: MOSS    Views: 951

I'm trying to convert an EventHandler fro sps 2003 for use with MOSS 2007.
I copied the project files from a Visual studio 2003 projects folder to a
Visual Studio 2005 projects folder and opened the .sln file with Visual
Studio 2005 and converted the project. The problem is in the EventSNK.vb.

OnEvent(ByVal listEvent As Microsoft.SharePoint.SPListEvent) Implements

The listEvent is underlined in green and the error is:

Warning 1 Type of parameter 'listEvent' is not CLS-compliant. ......

I thought it is just a warning, let's see what happens if I Build the
solution. Errors:

Error 1 The assembly 'Microsoft.SharePoint, Version=,
Culture=neutral, PublicKeyToken=71e9bce111e9429c' is not registered for COM
Interop. Please register it with regasm.exe /tlb. AllFacVTC
Error 2 The assembly "C:\Documents and Settings\robert.filipiak\My
Documents\Visual Studio 2005\Projects\AllFacVTC\bin\AllFacVTC.dll" could not
be converted to a type library. Type library exporter encountered an error
while processing 'AllFacVTC.EventSink, AllFacVTC'. Error: Error loading type
library/DLL. AllFacVTC

I tried searching for a sample on Microsoft with no luck. Where do I need
to look???



2 Answers Found

Answer #1    Answered By: Lynn Mann     Answered On: Jan 08

Event Handlers in MOSS have changed completely. Events in 2003 were
implemented through code added to the Global.asax. That is still
supported, but if you want to write the code as a .DLL you will need to
re-write the EventSNK to be a true EventHandler.

I don't have a sample, but its relatively simple. Here are the steps.

1. Create a Class Library project and add a reference to

2. Inherit your class in the class library from the
SPItemEventReciever class in the Microsoft.SharePoint Namespace

3. Override the method that represents the event you want to
handle. For example ItemAdding to process a new item during its
creation or ItemAdded to process it immediately after creation.

4. There is a parameter passed into the method called properties.
It contains a lot of useful properties, like the list where the item is
being added, the item itself, etc. There is also a Cancel property on
all the ...ing methods that can be used to cancel the process when set
to true.

5. Sign the Assembly and install it to the GAC.

6. Create a Web scoped Feature with a Feature.xml and an
Elements.xml to install and activate the feature. Actually, creating
the Feature is probably harder than writing the Eventhandler.

Answer #2    Answered By: Damini Dande     Answered On: Jan 08

I had tried using Event Handler Compatibility and copied the old .dll
into the GAC and assigned it in the Advanced settings of the form library and
the event sent emails as it was supposed to do but it did not update the Event
List the way it was suppose to.

Didn't find what you were looking for? Find more on MOSS 2007 EventHandler Or get search suggestion and latest updates.