locked
Accesssing an online Silverlight application from a locally stored HTML page RRS feed

  • Question

  • I have a question related to accessing an online Silverlight XAP file from a HTML page that is stored locally on my C:/ drive.  I will need the Silverlight application to access a large file that I would prefer to store on the client machine in order to speed up the whole process.  What I would like to do is to write the HTML file on the client’s hard drive with the required content embedded in it which in turn will trigger the Silverlight app who will be able to access the data in the DOM. 

    This works in Visual Studio but when I create the HTML page locally and open it, then the Silverlight app is not being run.  Either the app does not run and the page is empty or I am notified that Silverlight needs to be installed even though it already is.

    I am aware that running a Silverlight app as a trusted application will allow access to the hard drive but I am exploring options that will not require any user input in the process.

    I have tried adding the Silverlight section dynamically to the web page using JavaScript but this has not worked.  I get the same problems.  The JavaScript code is below and I’ve tested it from an online location and the Silverlight is being launched there.

    function applyChanges(){ 
    	  var theDiv = document.getElementById("silverlightControlHost");
    	  theDiv.innerHTML = '<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="http://online.company.net/ClientBin/company_xap.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="4.0.60310.0" /><param name="autoUpgrade" value="true" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0" style="text-decoration:none"><img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/></a></object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>';
    }
    

    I have been able to connect to the app using an iframe embedded in the local HTML file but this limits the access I require for the DOM in order to pull the required content.

    I have also tried loading HTML content into a WebBrowser control from memory in a Windows Forms Application but while the rest of the HTML is displayed, the Silverlight app is still missing.

    Is there any way to access an online Silverlight application from a local HTML file?

    Thursday, June 6, 2013 4:15 PM

Answers