0

I have create event receiver in dev environment and its working fine. But when try to add in production facing:

PS C:\Users\spfarmadmin> $spWeb = Get-SPWeb -Identity http://site/hr
PS C:\Users\spfarmadmin> $spList = $spWeb.Lists["EmpEntyExit"]

PS C:\Users\spfarmadmin> $spEventReceiver = $spList.EventReceivers.Add()

PS C:\Users\spfarmadmin> $spEventReceiver.Assembly = "$SharePoint.Project.Assemb
lyFullName$"

PS C:\Users\spfarmadmin> $spEventReceiver.Class = "my_STG.AddTaskand_SubTask
.AddTaskand_SubTask"

PS C:\Users\spfarmadmin> $spEventReceiver.Name = "AddTaskand_SubTaskItemAdded"


PS C:\Users\spfarmadmin> $spEventReceiver.Type = 10002

PS C:\Users\spfarmadmin> $spEventReceiver.SequenceNumber = 1000

PS C:\Users\spfarmadmin> $spEventReceiver.Synchronization = 1

PS C:\Users\spfarmadmin> $spEventReceiver.Update()

Exception calling "Update" with "0" argument(s): "Could not load file or assembly '.Project.AssemblyFullName$' or one of its dependencies. The system cannot find the file specified." At line:1 char:1 + $spEventReceiver.Update() + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : InvalidOperationException

PS C:\Users\spfarmadmin>

1
  • You can try providing assembly name like $spEventReceiver.Assembly = "YourAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5eff...(here goes assebly's token" "$SharePoint.Project.Assemb lyFullName$" is resolved when you use visual studio. Oct 24 '16 at 20:16
0

$SharePoint.Project.AssemblyFullName$ is a replacement token that VisualStudio will automatically replace with the real 4-part name of your assembly when you build the project.

What you can do is add a little Powershell snippet as an "external tool" in your Tools menu in VisualStudio which will output the 4-part assembly full name to the Output window in VS. Link here to the instructions on how to do that.

You can then use that information (the real 4-part name) in your Powershell above for adding the event receiver in production.

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.