Archive for the ‘Development’ Category

SharePoint – System.IO.FileNotFound Error in Console Application

Monday, February 28th, 2011

I was working on a console app that would use the SharePoint API to manage/validate some site settings. After writing out the “skeleton” of the application I tried to debug it with Visual Studio to make sure everything was working so far.When the application hit the first call that referenced the SharePoint API it would throw a System.IO.FileNotFound exception.

I searched around as I couldn’t understand what could be causing this. My executing account had full Rights in SharePoint, the local system and access to the database. I checked to ensure the url I was using was correct and that everything worked when viewing the site using a browser. Then I realized that Visual Studio by default sets Console applications to target x86 by default!!

(more…)

Sending an Email with PowerShell

Tuesday, February 8th, 2011

I was working on some build automation scripts today adding email notification of the build results. Since our automation scripts use PowerShell this is what I would be using to send the email. This turned out to be really straight forward task using the SmtpClient Class.

(more…)

SharePoint – Fixing Could not load type TaxonomyPicker

Tuesday, February 8th, 2011

I had been seeing this error time and again after recycling the app pool on one of my development boxes. After some digging online, it looks as though this is a bug that has snuck into the RTM release of SharePoint 2010. The TaxonomyPicker class does not exist within the SharePoint assembly, but the file is still in the control templates directory. So every time I recycle the app pool of my SharePoint web app, it tries to load the control and fails with a type exception.

(more…)

SharePoint – Displaying Custom Status Messages

Wednesday, January 5th, 2011

With SharePoint 2010 it’s much easier to display custom event & status information to a user using the Javascript Object Model. One of the new classes is the UI Status class (SP.UI.Status) which allows developers the ability to display custom “status messages” to users. These can be anything from informational messages to critical errors.

(more…)

SharePoint – Elevating Privileges

Tuesday, November 23rd, 2010

Many times during SharePoint development you may need to execute code or access information that the current impersonated user does not have access to. An internal example of this is SharePoint elevating calls to the database. Every application user doesn’t need assigned roles in SQL Server, only the SharePoint runtime accounts need to be configured for SQL Server access.

(more…)

SharePoint – Handling Access Denied Exceptions

Tuesday, November 23rd, 2010

Recently while working on a project, I ran into an issue with a site that was using forms based authentication (FBA). The application would load configuration settings before the user had logged in. If the application was in a state that the target site’s configuration had not been previously loaded & cached, then the request would be made as an anonymous (null) user. Since some of these settings were stored as SPWeb properties and the unauthenticated user does not have the required permissions the request would be denied and the user was redirected to a page stating that access was denied and they needed to login. The problem was they didn’t have a chance to login yet?!

(more…)

Using the WebPartStorage Attribute

Friday, November 12th, 2010

When developing custom webparts for SharePoint you may be required to persist data using properties. Depending on the specifics of the webpart you may want the value to be customizble per user or shared among all users. To do this you can decorate the property with the WebPartStorage Attribute. If a WebPartStorageAttribute attribute is not specified for a property, Personal is used by default.

(more…)