Tag Archives: SharePoint

Cannot start service SPUserCodeV4 on computer…!!!

Recently I started testing out SharePoint Online solutions. Its really hard to develop a webpart and test and debug it on Online itself(Because you need to upload solution, activate manually again and again). So I am using my SharePoint server installation and deploying my custom development as sandboxed solutions and then debugging them. When the webpart looks good I go deploy it on SharePoint Online.

When I created my first sandbox solution and try to deploy through Visual Studio 2010 it prompted me with an error.

Error occurred in deployment step ‘Activate Features’: Cannot start service SPUserCodeV4 on computer ‘KAMILSP2010’.

So I figured out this is something to do with missing of a service that needed to deploy or run any sandboxed solution. Little bit of googling helped me to sort it out the issue.

To resolve this you need to navigate to
SharePoint Central Administration –> System Settings –> Manage services on server

then search for the service “Microsoft SharePoint Foundation Sandboxed Code Service“ and start the service.

image

Then tried the Visual Studio deployment again, all went fine. Smile

The Web application at ” could not be found…!!!

Today a friend was trying to build a console application that will retrieve some list data from a SharePoint site. He had created a console application, added needed SharePoint assembly references and wrote down the following code segment to access the Site Collection and then to retrieve the Web site.

static void Main(string[] args)
 {
     try
     {
         string siteURL = "http://mySite/";

         using (SPSite site = new SPSite(siteURL))
         {
             using (SPWeb web = site.OpenWeb())
             {

             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }

The code get compiled without errors, and when try to execute the line for creating a new SPSite from given site url, it throws and exception. The exception is:

The Web application at ‘http://mySite/’ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

We both were pulling hair to figure out what is going wrong. Doesn’t seem like anything wrong.

Later figured out the console application build Platform Target was set to x86. So after changing it to x64 it started working fine. Smile

Deploy Resource Files in SharePoint…

While doing SharePoint projects definitely you will have to use resource files to well mange and localize your resources. Not like an ASP.net application SharePoint requires you to deploy resource files to different locations.

To be clear, different operations will look the resource files in two different locations(Web parts refer one location and the resource entries in a feature manifest file looks in another etc…). The two resource locations SharePoint will look into are,

1) C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14Resources

2) The web application Virtual Directory (typically C:inetpubwwwrootwssVirtualDirectories {the web application port number}App_GlobalResources

So when we deploy a solution what typically done is coping the resource files to these locations manually.
 
How to overcome these manual steps?
Read more »

Show Hide Existing Ribbon Options / Commands…

Once I wanted to hide some ribbon options for a given permission set. Basically, in SharePoint 2010 the rich text content area allows to insert web part directly on it. I wanted to security trim so, only the users that has Contributor permission level or higher would be able to perform the web part insert.

While figuring out how to do this, I came across an option that, to create a new custom control to perform the show hide ribbon options.

1) Create a custom control (inheriting from System.Web.UI.Control)

2) Override the OnPreRender method

3) Retrieve the ribbon from the current viewing page.

SPRibbon ribbon = SPRibbon.GetCurrent(Page);

Read more »

Set Properties on a List View Web Part…

Hey buddies. Smile Ever wanted to set some properties on a List View Web Part? Had issues doing it? End up with no solution? Here you have the solution.

Recent past I had a requirement to create a page instance with a Calendar Month view embed in a web part zone. So my first thoughts was to create a page manually, add the required calendar View to it, set all custom properties (hide chrome is the only thing I had to do) and export. Oh Gosh, at the last step I realized you cannot export the Calendar View Sad smile.

Any how reading through the net I found a way to export the Calendar List View. But it contains some GUIDs that refers to the Default View of the calendar, that is created when the web part is provisioned and that I cannot predict before hand. Now what?

Read more »

Check Current User Permissions…

I had a requirement to security trim some functionality in SharePoint to some user roles. Basically I wanted to display some controls / options in the Ribbon control to the users if they have “Design” permission level.

One thing to understand here is, SharePoint Security Groups has a group named, Designer. Checking is the current user in the Designer group will not be accurate. Because there can be new groups get created with the same permission set but with a different name. Also SharePoint allows you to add direct permission to users. (Not adding to a Group but directly give required permissions to the user itself).
Read more »

Display Document Type Icon in a DVWP

I had a requirement to display document icons inside a Data View Web Part. While googling I found some interesting information on this document types and there icons.

SharePoint has a pre populated list of document types along with respective images that maps to it. This document type to document icon image mapping can be found inside the file DOCICON.XML which can be located in the following location  C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEXML
Read more »

Recursive Data View Web Part…

Recently I had to give a hand to one of my friend to create a recursive DVWP. What this web part should do is to query all the sub sites including the root site, and retrieve all the Pages resides inside the Pages libraries. Also it should filter the retrieved pages for a given content type. Previously I had done whole lot of DVWP, but never wanted to create a recursive DVWP.

So how to achieve this,
Read more »

« Older Entries Recent Entries »