“Operation is not valid” when trying to create a List

I want to clone a list in Sharepoint. This is the code:

private static void CloneList(SPList sourceList, string targetListName)
    SPWeb web = sourceList.ParentWeb;
    web.AllowUnsafeUpdates = true;

    Guid targetListId;
    targetListId = web.Lists.Add(targetListName, sourceList.Description, sourceList.BaseTemplate);  
   // irrelevant stuff

On the last code line (Lists.Add()) I get the error

operation is not valid due to the current state of the object sharepoint 2010

any idea what to do to solve that issue? (running the code with elevatedPrivilegues does not solve the issue)


Try this...

targetListId = web.Lists.Add(targetListName, sourceList.Description, SPListTemplateType.CustomGrid)

Greats Hechler

Need Your Help

How to exclude headers from AST in clang?

c++ clang abstract-syntax-tree

I'm generating AST using clang. I've got following file (lambda.cpp) to parse:

formated output for doubles

c++ output

I want to know how I can, in c++, print for example 10 as 10.0000, or 10.1 as 10.1000.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.