Question

I am having a problem with visual studio 2008 websites and SharePoint/MOSS 2007. We previously had 2 web application projects housed underneath our SharePoint structure, but due to the nature of project files and source control, it was creating problems in our team development environment. I have decided to switch to from web applications to websites to remove the project file until I have time to change our source control to TFS. Everything works fine, however when I try and manually build one of the websites I get the following error:

This expression builder requires SPContext to run

Now this is not a real problem, due to the nature of websites and how they compile as needed upon loading. But it is a problem for my development team as we would really like to be able to get successful builds for various reasons.

The problem occurs through the use of a custom expression builder we use, which still works fine at runtime. It is only during compile that it gives us the error.

Any thoughts or ideas on how this problem can be overcome would be greatly appreciated.

Cheers,

Brendan

No correct solution

OTHER TIPS

SPContext.Current is used by many SharePoint applications to determine the current SharePoint context they are operating in. With the changes made this is obviously no longer possible in the build process.

One option is to build in some protection where if a valid SPContext can't be found, this is created with new SPSite/SPWeb objects as necessary to provide that context. This may require some rearchitecture depending on how the expression builder was designed, particularly because you would now need to correctly dispose of the created SPSite and SPWeb objects (something that's not required when using SPContext).

Another option is to use a mocking framework such as Typemock Isolator. This will mock/fake an SPContext. However you would need to rearchitect the code to use this as well I believe. On the plus side, you could stay with using SPContext only.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top