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:
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);
}
}
}
}
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
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:
Source File: C:\Software Development\user control\Relations.cs Line: 62
Stack Trace:
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);
}
}
}
}
}
}
}
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
is working on a reply...