Tuesday, November 9, 2010

Exception has been thrown by the target of an invocation.

While adding event receiver using issueList.EventReceivers.Add() I was getting following exception.

System.InvalidOperationException was unhandled
Message="Exception has been thrown by the target of an invocation."
Source="Microsoft.SharePoint"
StackTrace:
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidAssembly()
at Microsoft.SharePoint.SPEventReceiverDefinition.ValidReceiverFields()
at Microsoft.SharePoint.SPEventReceiverDefinition.UpdateInternal(Boolean isMigration)
at Microsoft.SharePoint.SPEventReceiverDefinition.Update()
at Microsoft.SharePoint.SPEventReceiverDefinitionCollection.Add(SPEventReceiverType receiverType, String assembly, String className)
at Company.WSS.DeployAndBindAssemblyToList.Program.RegisterEvents() in C:\Program Files\CustomPortal\Code\Company.WSS.DeployAndBindAssemblyToList\Program.cs:line 37
at Ellison.WSS.DeployAndBindAssemblyToList.Program.Main(String[] args) in C:\Program Files\CustomPortal\Code\Company.WSS.DeployAndBindAssemblyToList\Program.cs:line 13
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

It was because of the fact that I was using log4Net assembly for logging various activities and it wasn't added into GAC. Once added into GAC, above error gone away.

No comments: