Blog of Sundar Narasiman

Silverlight debugging problem: The Silverlight managed debugging package is not installed

I’m involved in developing Silverlight 3.0 development. My environment i s.NET 3.5 SP1, VS 2008 SP1 and Silverlight 3.0. It was working fine until i upgraded the silverlight runtime 4.0. I’m getting this error “Unable to start debugging. The Silverlight managed debugging package is not installed”.

I’ve learned that the fix for this is to install the Silverlight 4.0 install for developers http://go.microsoft.com/fwlink/?LinkID=188039

After installing this hotfix, i could able to debug Silverlight 3.0 applications in VS 2008, with Silverlight 4.0 installed side-by-side.

 Subscribe to my post

SharePoint 2010 Sandbox Solution Faqs

1.What is a sharepoint solution ?
The sharePoint solution is a deployable package that contain features and assemblies. It is a .cab based file with a .wsp extension. Visual Studio 2010 SharePoint Project template helps to create .wsp files. A solution can contain multiple features. Each feature can encapsulate functionality such as web parts, list definitons, modules and event receivers.

2.What is a sandboxed solution ?
The sandboxed solution looks and behavies like a farm solution, but the assembly of a sandboxed solution is set to allow partially trusted callers.

3.Is the structure of the sandboxed solutions different from farm solution running with full-trust?
It is similar in structure, but the main difference lies in how the sandboxed solution is deployed and executed.

4.Can a sandboxed solution run as a farm-solution ?
A sharepoint solution can be executed as farm-solution by providing full-trust.

5.How site-collection administrators manage the sandboxed solutions ?
The site-collection administrators can navigate to the solution gallery at the site-collection level and can upload, activate, delete and manage solutions. The gallery also enables a site collection administrator to monitor a solution’s usage against a resource quota.

6.How to deploy the sandboxed solutions to the site-collection ?
The sandboxed solutions can be deployed to the site-collection, just by uploading the .wsp file to the gallery and activate it.

7.How to retract the sandboxed solutions ?
The sandboxed solution can be retracted by removing the solution from solution gallery. The features associated with the solution need to be de-activated before
retracting the solution.

8.How to deploy the sandboxed solution from one site-collection to another ?
Copy the solution to disk and upload solution to another site-collection from the disk.

9.Can a sharePoint 2010 visual web part be packaged as sandboxed Solution ?
The visual web part needs .ascx file to be deployed to the file-system of web front-end. The sandboxed solution can’t deploy files to the
web front-end.

10.How to debug sandboxed solutions ? How different it is from debugging of full trust solutions ?
The full-trust solutions run under IIS worker process w3wp.exe. However the sandboxed solutions run under sandboxed worker process called spucworkerprocess.exe. Visual studio automatically attaches debugger when we hit F5. If we’re debugging a sandboxed solution that is already deployed, debugger needs to be explicity attached to the sandboxed worker process called spucworkerprocess.exe

11.What SharePoint components can be performed with Sandboxed solutions?
In a sandboxed solution, web parts, list definition & instances, content types, fields, modules, declerative workflows and event receivers can be created. All the classes below SPSite like SPSite, SPWeb, SPList and SPListItem are accessible inside sandboxed solution.

12.What are the permissions that are blocked for a sandboxed web part ?
a)Data-access outside of site-collection
b)Internet Access to make web service calls
c)Access to hard-drive for read/write files
d)Access to Partially trusted code

13.How to make sandboxed solution to reach outside world for performing trusted operation ?
Leverage Business Connectivity Services to read/write data outside of sandboxed solution. The other option is to invoke an assembly(class)deployed as full-trust solution. This proxy class can be called from sandboxed solution.

14.How to monitor the farm solution ?
SharePoint 2010 provides tools to monitor and set quotas on sandboxed solution. Farm administrators can navigate to
Central Administration –> Application Managment –> Configure Quotas and Locks in site-collection to configure Quotas and Locks.

15.How Quotas and Locks are managed ?
The Resource Quota properties for the user solutions can be set in the Site Quota Information section. 

 

 Subscribe to my post

Visual Studio 2010 SharePoint Power Tools

Visual Studio Team has released the SharePoint 2010 Power Tools for Visual Studio 2010. This would enable easier development of SharePoint 2010 Sandbox Solutions.

This is available in Visual Studio Gallery.

http://visualstudiogallery.msdn.microsoft.com/en-us/8e602a8c-6714-4549-9e95-f3700344b0d9

 

 

 Subscribe to my post

SharePoint Saturday India

SharePoint community is organizing the developer track of SharePoint Saturday event on May 8.  I’m speaking on the topic “Client Side Object Model of SharePoint 2010”.

If you are interested, register for the event

http://sharepointsaturday.org/india/Pages/sessions8thMay2010.aspx 

 Subscribe to my post

SharePoint 2010: Failed to register SharePoint Services on configuration wizard

When I was trying to install SP2010 beta2 on my laptop, in a stand alone, i got this error “SharePoint 2010: Failed to register SharePoint Services on configuration wizard ” during the

Script to automate the installation of wsp and activation of features

This post is regarding the usage of a simple script to automate the wsp installation and featue activation. Whenever we want to deploy components like custom web parts,  custom user control and custom application pages etc. we use sharepoint solution packages for deployment and then we activate the respective features manually. It is a tediou job to install the wsps and  activate the features manually, if we have multiple solution packages to be deployed. To automate this, we can use the the following script to install wsp and activate features. 

:begin
@echo off

set solutionName=SampleSolution
set featureSampleFeature1=SampleFeature1

rem ** Replace this value with the URL of your site **
@set url=http://yourserver/sites/rootsite/subsite

@set PATH=C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN;%PATH% 

stsadm -o retractsolution   -name %solutionName%.wsp -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name %solutionName%.wsp -override

echo Adding solution %solutionName% to solution store...
echo ----------------------------------------------------

stsadm -o addsolution -filename %solutionName%.wsp
if errorlevel == 0 goto :deploySolution

echo ### Error adding solution %solutionName%
echo .
goto end

:deploySolution
echo Deploying solution %solutionName%...
echo ----------------------------------------------------
stsadm -o deploysolution -name %solutionName%.wsp -url %url% -immediate -allowGacDeployment -allowCasPolicies  -force
stsadm -o execadmsvcjobs 

if errorlevel == 0 goto :activateFeature

echo ### Error deploying solution %solutionName%
echo .
goto end

:activateFeature

echo Activating features in solution %solutionName%...
echo ----------------------------------------------------

stsadm -o activatefeature -name %featureSampleFeature1% -url %url% -force

if errorlevel == 0 goto :success

echo ### Error activating features
echo .
goto end

:success
echo Successfully deployed solution and activated feature(s)..
echo .
goto end

:end
pause

In the above mentioned script, you can replace the solutionName with the name of your WSP and SampleFeature1 with the name of your feature to be activated. In this example, i'm activating a single feature. 
You can also mention multiple features in the script, so that multiple feature gets activated using this script.

 Subscribe to my post

Create secure sharepoint application page for site administrator

I’ve seen a question in msdn forum few days back, asking whether the sharepoint application page can be accessed only by the administrator. There is a simple way to achieve this. Whenever we create the secure application page in sharepoint, we need to override the property called RequireSiteAdministrator and return the value true. This would secure the application page in such a way that, it can be accessed only the site-administrator. Here is the code-snippet for the same. 

public class YourSampleApplicationPage : LayoutsPageBase {

  protected override bool RequireSiteAdministrator {
    get { return true; }
  }

  protected override void OnLoad(EventArgs e) {
    // any arbitrary logic goes here
  }
}

 Subscribe to my post

Create a custom web part to render silverlight application

In my previous post, I’ve discussed about how to leverage the content editor web part to render the silverlight application. In this post, I’d be discussing the steps to create a custom web part to render the silverlight application. The custom web part that renders the silverlight application has more advantages. Because things like attributes of silverlight application can be externalized as web part properties. Moreover security can be applied while rendering silverlight application, because the custom web part has power of code-behind support, rather than content editor web part. The whole idea is to render the silverlight control programmatically inside the web parts(using createchildcontrols method) . Here are the steps mentioned below :-

a)Import required namespace

Add a reference to System.Web.Silverlight.

using System.Web.UI.SilverlightControls; 

b)Programmatically add the script manager control to the page

To render the silverlight control, the ScriptManager object needs to added to the Page. Override the OnLoad method of web part, add the ScriptManager control using the following code-snippet. There needs to be only one instance of ScriptManager object registered with the Page object.

    protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //get the script manager associated with the current page
            ScriptManager oscriptManager =
                  ScriptManager.GetCurrent(this.Page);

            //check whether the script manager is already registered to the page
            if (oscriptManager == null)
            {
                oscriptManager = new ScriptManager();
                Controls.AddAt(0, scriptManager);
            }

        }

 

c)CreateChildControls method to render silverlight application

Override the CreateChildControls method and render the Silverlight control.

 protected override void CreateChildControls()
        {
            base.CreateChildControls();

            Silverlight oSilverlight = new Silverlight();
            oSilverlight.ID = “SLWPID”;
            oSilverlight.Source = “∼/ClientBin/YourSilverlightApp.xap”;
            oSilverlight.Width = Unit.Percentage(100);
            Controls.Add(oSilverlight);
        }

 Subscribe to my post

Leverage content editor web part to render silverlight application

Silvelight can be integrated with SharePoint sites to provide richness and improve the user experience of the SharePoint sites. There are many ways to integrate the silverlight application (xap) with SharePoint sites. The first option is to leverage the content editor web part and render the silverlight application (xap) through html and JavaScript. This is the simplest way to integrate silverlight applications with SharePoint sites. The other option is to to create a custom web part that does the rendering of the silverlight application.

In this blog post, I’d be sharing the steps to render silverlight applications by leveraging the  content editor web part.

Step1

Go the virtual directory in IIS, corresponding to the SharePoint web application. In my case it is C:inetpubwwwrootwssVirtualDirectories1111

Create a sub-folder by name silverlight_bin under the C:inetpubwwwrootwssVirtualDirectories1111

Copy the silverlight application (xap) from the bindebug directory of silverlight project  to the sub-folder silverlight_bin

Step2

Add the content editor web part to the page

Step3

Click ‘Modify shared web part’ and enter the following html snippet to the web part to the source editor of the content editor web part

<object
  data=”data:application/xsilverlight,”
  type=”application/xsilverlight2b2width=”400height=”300>

<param
  name=”sourcevalue=”/Silverlight_Bin/yoursilverlightapp.xap/>

</object>
Sometimes specifying the object tag in content editor web part may not work properly. If it does not work properly, we need create the object tags and other attributes using javascript.

 Subscribe to my post

Script to retract sharepoint solution package (wsp) and deactivate features

The following snippet contains the script to retract sharepoint solution packages and de-activate features. This would be become handy to the sharepoint adminstrators, when they want to retract multiple solution packages (wsp) and de-activate multiple features.

:begin
@echo off

rem ** declare the solution to be retracted **
set solutionName=SampleSolution

rem ** declare the set of fetures to be de-activated **
set featureSampleFeature1=SampleFeature1
set featureSampleFeature2=SampleFeature2
set featureSampleFeature3=SampleFeature3

rem ** Replace this value with the URL of your site **
@set url=http://servername/sites/sitecollectioname/sitename

@set PATH=C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12BIN;%PATH%

echo deactivating features in solution %solutionName%…
echo —————————————————-

stsadm -o deactivatefeature -name %featureSampleFeature1% -url %url% -force
stsadm -o deactivatefeature -name %featureSampleFeature2% -url %url% -force
stsadm -o deactivatefeature -name %featureSampleFeature3% -url %url% -force

echo Attempting to uninstallfeature and retract solution
echo —————————————————

echo Rectracting solution %solutionName% from solution store…

stsadm -o retractsolution   -name %solutionName%.wsp -immediate
stsadm -o execadmsvcjobs

echo Deleting solution %solutionName% from solution store…
stsadm -o deletesolution -name %solutionName%.wsp -override
echo.

if errorlevel == 0 goto :success
:success
echo Successfully deployed solution and activated feature(s)..
echo .
goto end

:end
pause

 

 Subscribe to my post