0

I cant seem to figure out what the issue is while I try to deploy my event receiver targeted at a particular list on my site.

All I am trying to do in the event receiver is to check (on itemUpdating) if property of a department field in a list item changes pop an alert.

I have checked out the following links but none of the solutions seem to fit my situation.

Error occurred in deployment step 'Activate Features': <nativehr>0x80070002</nativehr><nativestack></nativestack>

http://www.developersalley.com/blog/post/2012/09/01/How-To-Fix-The-NativeStack-Error-In-SharePoint-2010-When-Deploying-An-Event-Receiver.aspx

http://blogs.msdn.com/b/yardman/archive/2010/07/27/error-occurred-in-deployment-of-step-activate-features-the-field-with-id-defined-in-feature-was-found-in-the-current-site-collection-or-in-a-sub-site.aspx

Here is the code I have:

 namespace EmployeeTransferVS1.EmployeeTransferUpdating
{
/// <summary>
/// List Item Events
/// </summary>
public class EmployeeTransferUpdating : SPItemEventReceiver
{
    /// <summary>
    /// An item is being updated.
    /// </summary>
    ///string siteUrl = "";
    public override void ItemUpdating(SPItemEventProperties properties)
    {
        base.ItemUpdating(properties);
        try
        {
            if (properties.BeforeProperties["Department"] != properties.AfterProperties["Department"])
            {
                Console.Write(@"<script language='javascript'>alert('Updated');</script>");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

And here is the elements.xml file with my targeted ListURL

Please note that I have tested the url and the list access via my CAML builder and I am able to access and query just fine with the same account.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListUrl="EPD">
  <Receiver>
    <Name>EmployeeTransferUpdatingItemUpdating</Name>
    <Type>ItemUpdating</Type>
    <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
    <Class>EmployeeTransferVS1.EmployeeTransferUpdating.EmployeeTransferUpdating</Class>
    <SequenceNumber>10000</SequenceNumber>
  </Receiver>
</Receivers>
</Elements>

Any ideas/suggestions?

Thanks!

  • 1
    How u get Console.Write in event receiver class...? – Pushpendra Sep 21 '13 at 6:37
  • @Pushpendra I am just trying to make sure it is firing right in the first place. – user7400 Sep 23 '13 at 14:19
1

In your event receiver's Element.xml file,

In Place of the below code

<Receivers ListUrl="EPD">

Try with the follwoing code,

<Receivers ListUrl="Lists/EPD">

Note:

  1. ListUrl --> Specifies the URL of the list to which the event receiver applies to.
  • FYI: Its already been tried. I am able to deploy without the error when I just use the default list template line that was generated initially. THanks! – user7400 Sep 23 '13 at 14:17
0

I know this is old, but so is Sharepoint. I recently had this issue and I have been in search of the solution for this problem. My issue was a little different, but easily overlooked. My List was present on a sub-site.

If this is the issue for you, simply change the the site URL to your sub-site to the correct one and it will deploy.

Here is an excerpt from the article that helped me.

This is easy to fix – you just need to alter the Site URL for your project. To do this, single-click on your project name in the Solution Explorer (not the main Solution node, but the one under it). In the Properties pane, find the Site URL property, which you’ll see is set to your top-level site URL. Simply add the remainder of the URL to point to your subsite...

https://notuserfriendly.wordpress.com/2013/11/28/add-an-event-receiver-to-a-specific-list-instance/

I didn't even make it past the first bullet point and my issue was fixed. - Hope this helps someone out there.

  • Quote the main points from the article as links tend to go down. – Paul Strupeikis Jan 5 '17 at 16:06

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.