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

Forums / Developing with Sitefinity / Create Document Library through a web service

Create Document Library through a web service

6 posts, 0 answered
  1. Darren Irwin
    Darren Irwin avatar
    3 posts
    Registered:
    28 Oct 2009
    28 Oct 2009
    Link to this post
    Hi,

    I have a web service with a CreateLIbrary() method - I'm getting an error ">System.TypeInitializationException: The type initializer for 'Telerik.Libraries.LibraryManager' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.Libraries.LibraryManager..cctor() --- End of inner exception stack trace --- at Telerik.Libraries.LibraryManager..ctor() at CreateDocumentLibrary.DocumentLibraryService.CreateLibrary(String libraryName) in C:\Development\Gemini\AskGemmaSln\CreateDocumentLibrary\DocumentLibraryService.asmx.cs:line 32" when invoking the service?

    [

    WebMethod]

     

     

     

    public string CreateLibrary(string libraryName)

     

    {

     

     

    string libraryType = "Document";

     

     

     

    //TODO add date or time to name to make unique ??

     

     

     

    try

     

     

    {

     

    // create new instance of LibraryManager

     

     

    Telerik.Libraries.

    LibraryManager libraryManager = new Telerik.Libraries.LibraryManager();

     

     

     

    // create new library

     

     

    Telerik.Libraries.

    ILibrary addLibrary = libraryManager.CreateLibrary();

     

     

     

    // save value for Name property

     

     

    addLibrary.Name = libraryName;

     

    // Save what type of Library it is

     

     

    addLibrary.TypeName = libraryType;

     

    // save library item to database

     

     

    libraryManager.SaveLibrary(addLibrary);

    }

     

    catch (Exception ex)

     

    {

     

     

    return ex.Message;

     

    }

     

     

    return libraryName;

     

    }

    Many Thanks

     

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Oct 2009
    Link to this post
    Hi Darren Irwin,

    Thank you for using our services.

    When you are instantiating the Libraries manages, can you try to instantiate it with a provider name (the default one is Libraries). It seems that the library manager was not able to initialize properly. Also have you properly added the references to the Teleik.Libraries.dll in your web service?

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Darren Irwin
    Darren Irwin avatar
    3 posts
    Registered:
    28 Oct 2009
    28 Oct 2009
    Link to this post
    Hi,

    Thanks for your reply - so I should instantiate like this:
    LibraryManager libraryManager = new Telerik.Libraries.LibraryManager(Libraries);

    I have referenced the dll in the web service - this error also appears if you try to run from a console app to.

    Many Thanks
    Darren



  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    28 Oct 2009
    Link to this post
    Hi Darren Irwin,

    Can you try like this:
    LibraryManager libraryManager = new Telerik.Libraries.LibraryManager("Libraries");


    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Darren Irwin
    Darren Irwin avatar
    3 posts
    Registered:
    28 Oct 2009
    29 Oct 2009
    Link to this post
    Hi,

    Thanks for your support but I still receive the same error after instantiating like:
    LibraryManager libraryManager = new Telerik.Libraries.LibraryManager("Libraries");


    Many Thanks
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Nov 2009
    Link to this post
    Hello Darren Irwin,

    Do you call this code in the context of a Sitefinity application? Do you have the Sitefinity's bin assemblies in place, together with the web.config settings? I think that this is the problem.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 0 answered