Copied to clipboard

Flag this post as spam?

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

  • kukuwka 75 posts 96 karma points
    Mar 30, 2011 @ 13:57

    Create media using service


    I want to create new media using service that run every 5 hours.

    My code is:

    var media = Media.MakeNew(name, new MediaType(typeId), new User
    (0), parentId);
    return media.Id;

    But I receive the next error:

       at Cultiv.MediaLibraryCache.MediaCache.Cache(String cacheName)
       at Cultiv.MediaLibraryCache.MediaCache.RemoveFromCache(Int32 id)
       at Cultiv.MediaLibraryCache.MediaRemoveCacheHandler.RemoveFromCache(Int32 id)
       at Cultiv.MediaLibraryCache.MediaRemoveCacheHandler.SaveRemoveCacheItem(Media sender, SaveEventArgs e)
       at e) in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\cms\businesslogic\media\Media.cs:line 214
       at in d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\cms\businesslogic\media\Media.cs:line 41

    How can I avoid it?



  • Chris Randle 65 posts 176 karma points c-trib
    Jul 13, 2011 @ 19:07
    Chris Randle

    I am a bit of a newcomer to this Umbraco stuff - but I suspect that you are trying to using the Save method of the Media object without having a valid database connection underneath.   You are using Team City and it may be that it doesn't have sufficient privileges to host the application and connect to the database.  Basically - enough rights to save the Media object.

    Or alternatively, perhaps you can only call it from a valid HttpContext session.  Since Umbraco isn't running unless you have a current session open, this would explain this error message a little.

    Media.Save() should only be called directly from within a page. You need to look at another method of inserting Media.  I suspect using a valid webservice might do the trick.


Please Sign in or register to post replies

Write your reply to: