Amna Farhan
Amna Farhan

Reputation: 26

Sitecore Handlers

I am trying to create an event handler for sitecore .

I have done following steps.

  1. create a dll named "TestEventHandlers" and
  2. add its reference in bin folder of my website.
  3. Add following line in my web.config events --> event node: <handler type="TestEventHandlers.EventHandler , TestEventHandlers" method="OnItemSaved"/>

But i am getting following error:

Could not resolve type name: 
TestEventHandlers.EventHandler, TestEventHandlers.EventHandler 
(method: Sitecore.Configuration.Factory.CreateType(XmlNode configNode, String[] parameters, Boolean assert)).

I am confused about assembly name in type attribute of handler.

Upvotes: 1

Views: 1926

Answers (2)

Ghan
Ghan

Reputation: 351

Assuming dll name as- TestEventHandlers.dll , & class description as - namespace TestEventHandlers.Events{ public class EventHandler{...}} your handler entry shuld be < handler type="TestEventHandlers.Events.EventHandler , TestEventHandlers" method="OnItemSaved"/>

Upvotes: 0

Sean Kearney
Sean Kearney

Reputation: 4008

The assembly-qualified name of a type consists of the type name, including its namespace, followed by a comma, followed by the display name of the assembly. > MSDN

The assembly-qualified name for you class might look like this:

TestEventHandlers.EventHandler, TestEventHandlers

Assuming that your dll (assembly) is named TestEventHandlers and the class you wrote is called EventHandler within the TestEventHandlers namespace. In other words, you have this code in your TestEventHandlers dll and that dll is in the bin directory of your Sitecore web site.

namespace TestEventHandlers
{
    public class EventHandler
    {
        public void OnItemSaved(object sender, EventArgs args)
        {
        }
    }
}

Upvotes: 10

Related Questions