Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon steed 376 posts 688 karma points
    Mar 24, 2011 @ 12:32
    Simon steed
    0

    4.7 API issues again - Method not found Document.Copy(Int32, umbraco.BusinessLogic.User, Boolean)

    Upgraded to 4.7 to get over some other API issues which created another set of problems, now i'm trying to copy a node once it's been published to it's related cousin i.e. in a translated website but the API is being arsey again:

     

    Server Error in '/' Application.

    Method not found: 'Void umbraco.cms.businesslogic.web.Document.Copy(Int32, umbraco.BusinessLogic.User, Boolean)'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.MissingMethodException: Method not found: 'Void umbraco.cms.businesslogic.web.Document.Copy(Int32, umbraco.BusinessLogic.User, Boolean)'.

    Source Error:

    Line 60:             }
    Line 61:
    Line 62: }
    Line 63: }
    Line 64:


    Source File: C:\Software Development\user control\Relations.cs    Line: 62

    Stack Trace:

    [MissingMethodException: Method not found: 'Void umbraco.cms.businesslogic.web.Document.Copy(Int32, umbraco.BusinessLogic.User, Boolean)'.]
    AvectoUserControls.Relations.Document_AfterPublish(Document sender, PublishEventArgs e) in C:\Software Development\user control\Relations.cs:62
    umbraco.cms.businesslogic.web.Document.FireAfterPublish(PublishEventArgs e) +27
    umbraco.cms.businesslogic.web.Document.PublishWithResult(User u) +1520
    umbraco.cms.presentation.editContent.Publish(Object sender, EventArgs e) +236
    System.EventHandler.Invoke(Object sender, EventArgs e) +0
    umbraco.controls.ContentControl.savePublish(Object Sender, ImageClickEventArgs e) +46
    System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
    System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +120
    System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

     

    This is the code i'm using, taken direct from the EventSamples project on Umbraco.tv - are all api calls in 4.7 now broken????

     

    using System;
    using System.Collections.Generic;
    using System.Text;

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    using umbraco.cms.businesslogic.relation;
    using umbraco.cms.businesslogic.property;
    using umbraco.cms.businesslogic;

    namespace AvectoUserControls
    {

        //This class inhirites from ApplicationBase and is therefore automaticly instantiated on application_start.
        //All events are hooked-up using the constructor
        public class Relations : ApplicationBase
        {
            //Constructor
            public Relations()
            {
                //subscribe to the afterpublish events
                Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);
            }

            /// <summary>
            /// Executes after document publishing
            /// </summary>
            /// <param name="sender">The sender (a documet object).</param>
            /// <param name="e">The <see cref="umbraco.cms.businesslogic.PublishEventArgs"/> instance containing the event data.</param>
            void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
            {
                // if the parent doesn't already have been related
                bool hasCopy = false;
                if (sender.Relations.Length > 0 && sender.Level > 1)
                {
                    foreach (Relation r in sender.Parent.Relations)
                    {
                        if (r.RelType.Alias == "relateDocumentOnCopy")
                        {
                            hasCopy = true;
                            break;
                        }
                    }
                }

                // if the parent documentObject have a relation
                if (!hasCopy && sender.Level > 1)
                {
                    Document parent = new Document(sender.Parent.Id);
                    if (parent.Relations.Length > 0)
                    {
                        foreach (Relation r in parent.Relations)
                        {
                            if (r.RelType.Alias == "relateDocumentOnCopy")
                            {
                                sender.Copy(r.Child.Id, sender.User, true);
                            }
                        }
                    }
                }

            }
        }

    }

  • Simon steed 376 posts 688 karma points
    Mar 24, 2011 @ 22:48
    Simon steed
    0

    Sorted. Ok the reason this happened was due to me using a .net 3.5 class library project with the above code within which still referenced the older versions of the dll and 4.7 obviously being a .net 4 project.

    I've now rebuilt the library as a .net 4 and re-referenced the new dlls and it now works as described - took me a while to debug what was going on but now i'm motoring with this site

    Si

Please Sign in or register to post replies

Write your reply to:

Draft