Generally, you would use RunWithElevatedPrivileges to elevate permissions and execute a block code as the application pool account. But this doesn’t work nicely in console apps.
This is where I log all things SharePoint. I have worked on various versions of SharePoint. So, each post will usually specify what version I'm talking about (some times, the post will apply to pretty much all versions). Beyond SharePoint, this section may also hold content pertaining to other related Microsoft technologies like Office 365, Azure, C# (C Sharp), PowerShell, etc.
I have often needed to manage web parts programmatically in SharePoint using the server object model. While the requirements have varied depending on the specific situation, common things I have needed to do include programmatically adding, deleting and/or moving either custom webparts or OOTB web parts. I have also had to programmatically modify some OOTB web parts using the SharePoint server object model. I have an example of how to do this for the content editor web part in the last section of this article. This article provides quick code samples to manage web parts programmatically. Copy and paste and enjoy!
You have carefully developed a workflow with Visual Studio. Deployment and testing go smoothly on your dev machine. Some weeks or months later, the business requests some changes to the workflow. You implement the required changes and again deployment and testing (on your dev machine) also work fine. Now you try to upgrade the version you have on the production environment. And then the nightmare of versioning workflows begins…
When dealing with event receivers in SharePoint custom code, we use the BeforeProperties and AfterProperties to get a hash table of properties consisting of string/value pairs that correspond to fields in the SPItem object before and after the event occurred respectively.