1

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.

4

2 回答 2

10

类型的程序集限定名称由类型名称(包括其命名空间)、逗号和程序集的显示名称组成。> MSDN

您的类的程序集限定名称可能如下所示:

TestEventHandlers.EventHandler, TestEventHandlers

假设您的 dll(程序集)已命名TestEventHandlers,并且您编写的类EventHandlerTestEventHandlers命名空间中被调用。换句话说,您的 dll 中有此代码,TestEventHandlers并且该 dll 位于您的 Sitecore 网站的 bin 目录中。

namespace TestEventHandlers
{
    public class EventHandler
    {
        public void OnItemSaved(object sender, EventArgs args)
        {
        }
    }
}
于 2012-05-21T12:55:01.570 回答
0

假设 dll 名称为 - TestEventHandlers.dll 和类描述为 - namespace TestEventHandlers.Events{ public class EventHandler{...}} 您的处理程序条目应该是 < handler type="TestEventHandlers.Events.EventHandler , TestEventHandlers" method="OnItemSaved "/>

于 2016-11-06T15:35:03.817 回答