0

I tying to attach event receiver via powershell but facing this issue:

$list = (get-spweb http://site/it).lists['IT Support Request']
$def = $list.EventReceivers.Add() 
$def.Assembly = "$SharePoint.Project.AssemblyFullName$" 
$def = $list.EventReceivers.Add()
$def.Assembly = "$SharePoint.Project.AssemblyFullName$"
$def.Class = "esolution_STG.CreateITSupportTicket.CreateITSupportTicket"
$def.Type = [Microsoft.SharePoint.SPEventReceiverType]::ItemUpdated
$def.Name = "CreateITSupportTicketItemUpdated";
$def.Synchronization = [Microsoft.SharePoint.SPEventReceiverSynchronization]::Synchronous
$def.Update()

Here is the issue:

Exception calling "Update" with "0" argument(s): "Could n assembly '.Project.AssemblyFullName$' or one of its depen cannot find the file specified." At line:1 char:1 + $def.Update() + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], Metho + FullyQualifiedErrorId : InvalidOperationException

How to fix this issue?

0

Use fully qualified name of your assembly (e.g. MyNamespace.MyAssembly, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089) instead of $SharePoint.Project.AssemblyFullName$. Here is a guide on how to get it from within Visual Studio. As far as I know, $SharePoint.Project.AssemblyFullName$ can only be used decoratively (XML).

Keep in mind that your code is adding two event receivers and only the last one is updated:

$def = $list.EventReceivers.Add() $def.Assembly = "$SharePoint.Project.AssemblyFullName$" $def = $list.EventReceivers.Add() $def.Assembly = "$SharePoint.Project.AssemblyFullName$"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.