Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

SharePoint, Web Parts, MVP Pattern Gotcha

Posted by Steve Pietrek on May 21, 2007

Whew, this one was a head scratcher!

I am in a beginning stages of a R&D project to ensure any web parts created work in both SharePoint as well as another team’s ASP.NET 2.0 application. To help with testing, I want the make use of the MVP (Model-View-Presenter) Pattern to allow for easier testing of code using MbUnit. My first pass at the web part, which did not use the MVP Pattern, contained one Personalizable property named “Connection”. After successfully deploying the assembly to SharePoint (more on this in a later post), I was able to successfully edit the web part and see the data in a DataGrid. My next step was to create a separate assembly to contain my View and Presenter namespaces. The view (see code below) had 3 properties – one getter, one getter/setter, and one setter.

public interface ISalesView
{
string SalesConnectionString { get; }
DataSet SalesDataSet { get; set; }
string SalesErrorMessage { set; }
}

 

After making the changes, I created a separate ASP.NET website to test my new changes. Everything worked correctly – again I was able to edit the web part and see the data. The next step was to copy the new assembly along with my newly compiled web part assembly to my SharePoint virtual directory’s bin directory. I hit F5 to refresh the screen in IE and the web part displayed properly since the “Connection String” was already stored in the content database. Great! I then attempted to edit the web part and received the following error: “An unexpected error has occurred.” Whoa, that’s not very helpful! I checked out the log and didn’t see anything in there worth noting. After trying multiple things, a workaround was to give the SalesErrorMessage property a “getter”.

public interface ISalesView
{
string SalesConnectionString { get; }
DataSet SalesDataSet { get; set; }
string SalesErrorMessage { get; set; }
}

Weird!

Advertisements

One Response to “SharePoint, Web Parts, MVP Pattern Gotcha”

  1. […] SharePoint, Web Parts, MVP Pattern Gotcha […]

Sorry, the comment form is closed at this time.

 
%d bloggers like this: