Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Tuesday, June 21, 2011

Sharepoint 2010 : Deploying a WSP package to remote server easily

By using Sharepoint Management Console,

1) Uninstall-SPSolution -Identity package.wsp -WebApplication http://server
2) Remove-SPSolution –Identity package.wsp
3) Add-SPSolution "C:\blabla\package.wsp"
4) Install-SPSolution –Identity PernodTC.wsp –WebApplication http://server


Tuesday, December 22, 2009

SPFile Item Update Error: Operation is not valid due to the current state of the object.

It's very frustrating and can take a whole working day: You are trying to update a library (list) item from Sharepoint object model and getting this error continiously.

In fact, solution is simple: RunWithElevatedPrivileges is working buggy in Sharepoint 2007, so the best things is avoiding putting code in it as much as possible.

For instance, if you want to simply update "Title" of an item in your document library, it should appear like this;

SPFile FileToModify = null;
SPSite ElevatedSite = null;
SPWeb ElevatedWeb = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite Site = new SPSite(SiteCollectionUrl))
{
ElevatedWeb = Site.RootWeb;
ElevatedSite = Site;
}
});

SPItem Items = FileToModify.Item;
ElevatedSite.RootWeb.AllowUnsafeUpdates = true;
Items["Title"] = "new title";
FileToModify.Item.UpdateOverwriteVersion();
ElevatedSite.RootWeb.AllowUnsafeUpdates = false;
Returning = "ok";

--

Then you won't face any errors.

Tuesday, July 29, 2008

Beginner! An easy start to SharePoint / MOSS 2007 development

I was only experienced on Microsoft SharePoint as a basic user, which was a part of Small Business Server. When my boss came with a contract to develop a SharePoint system for a serious chain of compaines in Germany, I said ok, how difficult it can be?

However, one of the difficulties that SharePoint has is, setting up the development enviroment. You have to install many stuff on your computer, including Windows Server 2003, SharePoint Server, Visual Studio and probably SQL Server and so on.. Damn, only installation will take more than one day and setting up the user accounts, permissions etc. will probably take another one too.

Microsoft made a great work to kick this out : They've created a virtual image (VHD) file including a 30 days trial version of Windows Server 2003 with all configuration done; including a very well configured SharePoint Server, a basic version of Visual Studio 2005 and Microsoft Word etc. Here is the link :

http://www.microsoft.com/downloads/details.aspx?familyid=67f93dcb-ada8-4db5-a47b-df17e14b2c74&displaylang=en

Microsoft Virtual PC 2007 runs it so fast and stable. Of course Virtual PC 2007 is free to download too.

For my purposes I installed Visual Studio 2008, SharePoint Extensions for Visual Studio too. Magic! I liked it.

Notice : Suddenly Windows Server 2003 makes a Windows Update and it stops SharePoint to respond. It's better to turn Automatic Updates off in first run.