When using Silverlight to develop web parts for SharePoint 2010, you might use the Silverlight Client Object Model to access SharePoint data. But what happens if you try to move out of the Silverlight web part and, for example, put Silverlight in a SharePoint dialog box? Answer: Unhandled Error in Silverlight Application Object reference not set to an instance of an object at ClientContext.Current.
The problem arises because the Silverlight web part injects the SharePoint context into the HTML object parameter for the proper functioning of the Client Object Model. Therefore, you need to inject the SharePoint site URLs where the Silverlight is currently displayed into the initParams (MS.SP.url):
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="MySilverlightFile.xap" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.41102.0" />
<param name="autoUpgrade" value="true" />
<param name="windowless" value="true" />
<param name='initParams' value='MS.SP.url=<%= SPContext.Current.Site.Url%>/<%=SPContext.Current.Web.ServerRelativeUrl %>' />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41102.0" style="text-decoration: none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
style="border-style: none" />
</a>
</object>
You can now move out of the Silverlight web part in SharePoint.