Copied to clipboard

Flag this post as spam?

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


  • Erik 5 posts 35 karma points
    Sep 11, 2012 @ 09:29
    Erik
    0

    Document.MakeNew from class library

    Hi all,

    I'm looking for a way to create new nodes from a class library to synchronize data between an external database and Umbraco. Using the Document.MakeNew method works fine when called from an Umbraco web application. But it throws an exception when being called from a class library that has all the same configuration items.

    Code:

    DocumentType dt = DocumentType.GetByAlias(newDocumentType);
    User author = User.GetUser(0);
    Document doc = Document.MakeNew(newDocumentName, dt, author, parentDocumentId);
    doc.Publish(author);

    The type initializer for 'umbraco.UmbracoSettings' threw an exception.

    Value cannot be null. Parameter name: str

       at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)

       at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)

       at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)

       at System.Web.InternalSecurityPermissions.get_AppPathDiscovery()

       at System.Web.HttpRuntime.get_AppDomainAppPath()

       at umbraco.GlobalSettings.get_FullpathToRoot()

       at umbraco.UmbracoSettings..cctor()

     

    Strange thing is, the node is created in the Umbraco database but it's not published.

     

    Regards,

    Erik

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 11, 2012 @ 17:42
    Jeroen Breuer
    0

    The Umbraco API won't work outside of an Umbraco environment. Also see this answer: http://stackoverflow.com/questions/3873952/umbraco-document-getproperty-value-throws-null-reference-exception#3899490

    Jeroen

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 11, 2012 @ 22:07
    Richard Soeteman
    0

    Hi,

    As Jeroen says it's not possible at the moment. For importing data you might want to checkout CMSImport it supports SQL Server in the free version.

    Cheers,

    Richard

  • Erik 5 posts 35 karma points
    Sep 12, 2012 @ 08:54
    Erik
    0

    Hi Jeroen and Richard,

    Thanks for your answers. It's a shame we can't do this import in a Windows Service running in the background!
    I've tried the CMSImport package and it seems to work fine. We'll obviously need the Pro version.

    Erik

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Sep 12, 2012 @ 08:59
    Richard Soeteman
    0

    Hi Erik,

    I think it will change in the future but for now it's not possible. Thanks for trying CMSImport.

    Thanks,

     

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft