Security excpetion while using SharePoint Object Model in Silverlight
-
Friday, June 17, 2011 6:56 AM
HEllo All, I am new to SharePoint and got stuck in one issue which is as follows:
I am creating New Folder in any existing directory in SharePoint Site via Silverlight.
The Code I Wrote is as :
ClientContext clientContext;
bool exists;
List list;
string folderName;
public void CreateFolder_ClientOM(string listName, string fName)
{
folderName=fName;
clientContext = new ClientContext("http://eni-dev09:17025");
Web web = clientContext.Web;
list = clientContext.Web.Lists.GetByTitle(listName);clientContext.Load(clientContext.Site);
string targetFolderUrl = listName + "/" + folderName;
Folder folder = web.GetFolderByServerRelativeUrl(targetFolderUrl);
clientContext.Load(folder);
exists = false;ThreadPool.QueueUserWorkItem(new WaitCallback(abc));
}
void abc(Object stateInfo)
{
try
{
clientContext.ExecuteQuery();
exists = true;
}
catch (Exception ex)
{ }
if (!exists)
{
ContentTypeCollection listContentTypes = list.ContentTypes;
clientContext.Load(listContentTypes, types => types.Include
(type => type.Id, type => type.Name,
type => type.Parent));var result = clientContext.LoadQuery(listContentTypes.Where
(c => c.Name == "Folder"));clientContext.ExecuteQuery();
ContentType folderContentType = result.FirstOrDefault();
ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
newItemInfo.LeafName = folderName;
ListItem newListItem = list.AddItem(newItemInfo);newListItem["ContentTypeId"] = folderContentType.Id.ToString();
newListItem["Title"] = folderName;
newListItem.Update();clientContext.Load(list);
clientContext.ExecuteQuery();}
}
I Am Calling The Function as
CreateFolder_ClientOM("SLXAPLib","NEW");
I am Getting Security Exception......????
What May Be the Cause?
thanks in Advance.

