Good Morning,
I am new to sharepoint but I am pretty salty as far as silverlight goes. I know on a standard silverlight application hosted inside an ASP.NET app you can simply append .xap? here to make sure the xap files does not cache each time. In SharePoint I found only one article that even came close to exphttp://techblog.m-dd.com/index.php/2013/01/25/resolve-sharepoint-silverlight-webpart-caching-problem/. When I trying to Edit the WebPart and Under Application, provide path to .xap I click Configure. I then appent something like this to the end of the xap file: .xap?ver=1.1.1.0002 and recieve the following error in sharepoint: Cannot save all of the property settings for the Web Part. One or more errors have occured.
Any help would be greatly appricated.
Thanks
In my experience I've had a lot more luck by using a Content Editor Web Part and then embedding the tag which then links to the .xap file from there. Essentially you can edit the HTML source of the page by adding such a web part.
In the Content Editor Web Part, select "Edit Source" and paste something similar to this:
<object width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="/Library/YourSilverlight.xap?v=1"/>
</object>
See embedding Silverlight here: http://tz.nu/1o9pkSk
See more about adding the Content Editor Web Part here: http://tz.nu/1tSCOnJ
Using this approach, you can simply modify the page and edit the CEWP (Content Editor Web Part) and append the querystring behind the .xap to something unique (in my case, perhaps increment it to YourSilverlight.xap?v=2).
As an alternative to all of the above;
I've oftentimes developed my own base web part which hosts Silverlight .xap files, then I'll deploy and add that Web Part instead. I've often built-in the functionality for updated versions into the code so you never have to do that manually, but that's another story.
Related
Having clients over the globe, we encountered some serious loading delays for initially retrieving the XAP from various locations. The hope was that we could host the compiled XAP in the cloud, offering a closer download depending on the end-user's location.
We are using RIA services, but the service endpoints need to remain on our local server, because of data connections, connections to internal services, etc.
How do we distribute the XAP using cloud-based services, while having it continue to function the same as it does currently?
EDIT: Since I worked through this and found the answer myself, I've moved the steps that I had accomplished before out of my question and into the answer to better facilitate a good Q&A format and for anyone else approaching the problem from step zero.
After hammering away at this, I found the solution to get it almost completely working.
Update RIA service endpoints with absolute URIs to refer back to the hosting page rather than relative to the XAP location itself.
Ensure all image (etc.) content is loaded from either resources in the XAP or else ensure they are uploaded as well to the Azure Storage Blob. Any relative paths will try to resolve to the XAP location.
Generate the XAP file and upload to the Azure Storage Blob. You will need to ensure that the XAP has Content-Type of application/x-silverlight-app. I accomplished this using Azure Storage Explorer. You can set Content-Type by opening the properties of the item via double-click, but, and even better, you can click the Settings gear to 'Edit Content Types' and add a rule that .xap is application/x-silverlight-app so that it will be automatically set any time you upload.
Ensure you have a proper cross domain policy in place.
Update your hosting page to supply the new source. Additionally, you will need to add the enablehtmlaccess param if not already set, since this value is false by default for cross domain.
For item #1, I accomplished using code such as the following:
var u = HtmlPage.Document.DocumentUri;
Site = u.AbsoluteUri.Substring(0, u.AbsoluteUri.LastIndexOf('/'));
MyServiceUri = new Uri(Site + "/ClientBin/My-Namespace-MyService.svc", UriKind.Absolute);
For item #4, my code looked like:
<param name="source" value="<%= Request.Url.Scheme %>://mytest.blob.core.windows.net/my-container/MySilverlightApp.xap"/>
<param name="enablehtmlaccess" value="true" />
One last thing to note: If using a custom splash screen, then figure out how to get this to work. I don't know how. What I have found out is that if you set splashscreensource as the location of a .xaml file, then it simply does not load. It will just show the basic silverlight load percent screen, which does at least seem to report load % correctly. In order to get the custom splash screen to load, it seems to only work when included inline. You can do this via:
<script id="xamlSplash" type="text/xaml">
<%= System.IO.File.ReadAllText(Context.Server.MapPath("~/Loading.xaml")) %>
</script>
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="splashscreensource" value="#xamlSplash" />
However, while this will show the custom splash screen, it will not work if you have any progress report on the splash screen. The javascript function referenced by onsourcedownloadprogresschanged will never fire. I could not find why this was the case, nor a way around it. You'll just have to have a spinning animation or the like in place of an actual % progress indicator.
We have an asp:Silverlight tag on one of our aspx pages and has been working happily for years:
<asp:Silverlight ID="Xaml1" runat="server" MinimumVersion="2.0" Source="~/ClientBin/FHH.UploadManager.xap" Width="97%" Height="320" />
The user selects multiple files, which are listed in the Silverlight API, then the user left-clicks on a file and selects what type of file it is, then the files are uploaded and end up in different folders depending on the type.
As an enhancement it is required that we have another type and we amended the Silverlight project to include this extra type, creating a new xap file. This worked fine in test but when it was built for the live environment the Silverlight tag disappears from the screen.
I have browsed through various forums, including Stackoverflow and found the suggestion that we should use <object>, but when I tried that it gave an error message: ‘Could not download the Silverlight application’.
Any help will be appreciated.
We have resolved this problem, we were trying to point to a web service with the wrong URL, 2 URLs could be used and we were using the wrong one.
I am totally to Silverlight and am Getting started. I finished the first of the Getting started series here and now seeing into HTML Bridge now over here. Visual Studio created a website for me when it created the new silverlight application. For the HTML bridge tutorial I created another silverlight page(Is this what i should create) and put some code into it.
Question
How do I embed this into a html page? ( I know how to do it using markup as well as javascript, I am confused as to how to get the application out of single xap file inside ClientBin directory)
With Silverlight you are dealing with a single plugin within a HTML page. That plugin is the single XAP file that the HTML page downloads.
Your Silverlight app may also have many pages, but its navigation is not the same as HTML navigation (it uses bookmark URLs to fool the browser into staying on the same page while it changes content). There is only the one HTML page involved.
Initially, just to test your new page, you can change the app.xaml.cs file to create your new Silverlight Page instead of RootVisual = new Main() etc. Long term you need one Silverlight application per separate plugin your require.
Update (from comments):
Pages in Silverlight are changed by substituting a visual element of the single main page with the contents of another Silverlight page.
You cannot simply replace the RootVisual (as that can only be set at startup).
Start with a new Navigation or Business application project to see the basics (navigation adds a lot of complexity, but once you see how it works it is pretty cool).
I have a Silverlight app made in Visual Studio 2010 and I want to put it on a website but I don't have the slightest clue how.
I've looked at all the msdn documentation and they all mention a .xap file that is the file you use on the website but there is no .xap and I can't find out how to compile my code into a .xap file.
Also, when I run the App and look at the source in the browser, it has my code compiled into the .xap file, but there is no .xap file!
So my question is simply how do you go about getting a Silverlight app on a website because I've been trying for hours and I can't figure it out.
A sample html or aspx page is included when you create the solution. This is the page that the browser navigates to when you hit F5. You can take that page as a basic example of how to embed a Silverlight app in a page. You should find it in the project folder.
Silverlight projects are commonly built into a XAP file when you hit "Build" in VS. This file lives in the bin/Release or bin/Debug folder and basically contains your whole application.
Steps to create a silverlight application Hosted in a web site,
Select Silverlight Application Template while adding new project in VS2010
When you click Ok, ensure that Host the Silverlight application in a new web site is Checked.(It will create a new ASP.Net web application to host the Silverlight)
If you haven't checked the Host the Silverlight application in a new web site option, you can add a new ASP.Net Web application project and then go to its properties and select Silverlight Applications option in left pane. Then Click Add, select your Silverlight Application to be hosted and click ok. You are done now.
But If haven't selected the Silverlight Application Template, then you might have created a Silverlight Class Library. It wont generate any xap file. It just gives a dll. So you need to recreate a project as mentioned above.
I believe that in Silverlight whenever you create a project, right at the beginning, it will ask you if you want to create a web app automatically. If you chose yes, something like YOUR_PROJECT_NAME.web will be created, go into that folder, you will find a folder called ClientBin.
The .xap file will be inside that folder.
HTH
How can I embed a demonstration applet written in Silverlight within a blog post? Is it possible to do so using any hosted blog engines, or only using a blog engine that I host myself?
I assume that I will need to use the same tags and .js as in a regular (X)HTML page with a SL control. Are there any hosted blog engines that will permit me to enter this? (Is it possible with blogger?)
Does the SL security model mean that the XAP file need to be hosted on the same site as the blog pages itself?
You can host a Silverlight app in HTML using the <object> tag, there is no need for the blog host to understand any of this. There is no server side element to hosting a Silverlight app its a purely client side thing.
<object id="SL" data="data:application/x-silverlight-2," type="application/x-silverlight-2" style="width:400px; height:300px">
<param name="source" value="MySLApp.xap" />
<param name="minRuntimeVersion" value="3.0.40624.0 />
<param name="initParams" value="someParam=value" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" style="border-style: none" alt="Get Microsoft Silverlight" />
</a>
</object>
In this case the Silverlight app "MySLApp.xap" is placed in the same folder as the HTML page using it. However it could be on a different server if you like. However access to the HTML Bridge will be blocked but then if your app is self contained and does not need to communicate with the host page then there is no problem.
I created a Silverlight xap to host hero images OR video in my wordpress theme - I pass the content to it using initparams and custom fields per post.
That way I can use the same xap to host videos with media controls if appropriate or images with cool fade ins/click effects
example image post:
http://www.blackspike.com/site/html/display-google-docs-spreadsheets-in-wordpress
example video post (click vid for controls):
http://www.blackspike.com/site/wpf/hanselmans-babysmash
Both using the same xap!
An easy solution that worked for me is just to use an iFrame. So I published the regular TestPage.html generated by Visual Studio to my web site (along with the .XAP file of course) and then embedded it:
<iframe src="http://www.lostbearlabs.com/sl/Spring001/TestPage.html" frameborder="0" width="400" height="400" scrolling="no" ></iframe>
Using blogger, I discovered this gotcha: Any attempt to make the HTML pretty (e.g. by splitting it into separate lines) causes blogger to insert spurious <br> tags into the output, even if I do my edits using the "Edit HTML" view. So the iFrame tag must all be on a single line!!
You might want to check your host has the required MIME types mapped:
http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/
according to this Server 2008 IIS7 should work out of the box but IIS6 may require MIME types adding...
The solution marked as answer above works well if the HTML page and the Silverlight xap file are hosted on the same server.
As this is not possible in most of the cases, as most of the bloggers use either blogger/WordPress. We do not have any way of setting the mime type on these hosting providers.
Here is a good link which explains in detail regarding hosting an Silverlight application in blogger.