I have made a web part in Visual Studio in which I am using the following class:


It is working fine. Then I created a new visual web part project and tried to use this but it says:

The type or namespace name 'SPServiceContext' could not be found (are you missing a using directive or an assembly reference?)

Even though I have already added Microsoft.SharePoint at the top plus I have added its reference in project.

How to fix this?

  • Are you using Sandboxed solution? This class is available only in farm solutions. – Evgenii Vilkov Nov 14 '13 at 11:55
  • Yes I am using sandboxed solution. Looks like you are right because the other project in which it is working is not sanboxed solution. – Frank Martin Nov 14 '13 at 12:21
  • You can check availability of class in sandboxed solution on MSDN. There is a 'Available in Sandboxed Solutions' parameter (but only in SP 2010 page version). – Evgenii Vilkov Nov 14 '13 at 13:22
  • What are you trying to accomplish? Maybe we can help you with an alternate method... – John Chapman Nov 14 '13 at 14:35
  • I have a an external list with column "employee id". I am making a web part which will pass current logged in user's employee id (which is coming from UPS/AD) and then display records to him. – Frank Martin Nov 14 '13 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.