+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Modifying Libraries problem with LibraryManager.GetLibrary(String name)

Modifying Libraries problem with LibraryManager.GetLibrary(String name)

2 posts, 0 answered
  1. Scott
    Scott avatar
    2 posts
    Registered:
    09 Jun 2008
    03 Mar 2009
    Link to this post
    When trying to manually manage a library, I found I couldn't update the library when calling LibraryManager.GetLibrary(String name).

    If I tried the following code I would get an error 'You cannot change a value of an object that is not in transaction.'

    LibraryManager libraryManager = new LibraryManager(); 
    ILibrary parentLibrary = libraryManager.GetLibrary("oldname"); 
     
    if (parentLibrary != null) 
        parentLibrary.Name = "newname"
        libraryManager.SaveLibrary(parentLibrary); 

    However if I change the code to the following it worked fine.

    LibraryManager libraryManager = new LibraryManager(); 
    ILibrary parentLibrary = libraryManager.GetLibrary("oldname"); 
                 
    if (parentLibrary != null) 
       ILibrary library = libraryManager.GetLibrary(parentLibrary.ID); 
       library.Name = "newname"
       libraryManager.SaveLibrary(library); 


    Regards,
    Scott
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Mar 2009
    Link to this post
    Hi Scott,

    This is a Nolics error, every object has to belong to a transaction before you do any persistence with it.
    You are directly calling Nolics code, as the ILibrary object is a Nolics object. Hence the object is not joined into a transaction.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered