Update silverlight xap file
-
Hi, I am working on a silverlight project. In this when I try to publish my code It failed and it didn't gave me any error. So I took the old application for which publish is successfull and modified it with the changes in the code. Now the .xap file is now updating my chages and it is displaying the old functionality. If anyone have any idea to make the publish successfull or update the .xap file , please reply me. Thanks in advance.
-
Hi, I am working on a silverlight project. In this when I try to publish my code It failed and it didn't gave me any error. So I took the old application for which publish is successfull and modified it with the changes in the code. Now the .xap file is now updating my chages and it is displaying the old functionality. If anyone have any idea to make the publish successfull or update the .xap file , please reply me. Thanks in advance.
-
Hi, I am working on a silverlight project. In this when I try to publish my code It failed and it didn't gave me any error. So I took the old application for which publish is successfull and modified it with the changes in the code. Now the .xap file is now updating my chages and it is displaying the old functionality. If anyone have any idea to make the publish successfull or update the .xap file , please reply me. Thanks in advance.
OK, here's an extended version. This code appends the file date/time to the XAP file name. This way you'll keep the caching of already loaded XAP files and you don't have to remember to change the number...
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);const string XAP = "ClientBin/XapFile.xap"; System.IO.FileInfo fi = new System.IO.FileInfo(Request.MapPath("./" + XAP)); string timeStampXAP = fi.LastWriteTime.ToString("yyyyMMdd\_HHmmss"); source.Text = String.Format("<param name=\\"source\\" value=\\"{0}?{1}\\" />", XAP, timeStampXAP); }
</script>
<%@ OutputCache Duration="1" VaryByParam="None" Location="None" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
form {
height: 100%;
}
#host {
height: 100%;
text-align:center;
}
</style>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
window.onload = function()
{
document.getElementById('host').focus();
}function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\\n"; errMsg += "Code: " + iErrorCode + " \\n"; errMsg += "Category: " + errorType + " \\n"; errMsg += "Message: " + args.ErrorMessage + " \\n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \\n"; errMsg += "Line: " + args.lineNumber + " \\n"; errMsg += "Position: " + args.charPosition + " \\n"; }
-
Hi, I am working on a silverlight project. In this when I try to publish my code It failed and it didn't gave me any error. So I took the old application for which publish is successfull and modified it with the changes in the code. Now the .xap file is now updating my chages and it is displaying the old functionality. If anyone have any idea to make the publish successfull or update the .xap file , please reply me. Thanks in advance.
I don't know if zlezj's solution is necessary, but... During development I've noticed sometimes the browser will use a cached xap instead of my freshly changed xap, so I just got in the habit of clearing the browser cache every time I test. Also make sure your newer xap files are actually overwriting old ones when you publish.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
OK, here's an extended version. This code appends the file date/time to the XAP file name. This way you'll keep the caching of already loaded XAP files and you don't have to remember to change the number...
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);const string XAP = "ClientBin/XapFile.xap"; System.IO.FileInfo fi = new System.IO.FileInfo(Request.MapPath("./" + XAP)); string timeStampXAP = fi.LastWriteTime.ToString("yyyyMMdd\_HHmmss"); source.Text = String.Format("<param name=\\"source\\" value=\\"{0}?{1}\\" />", XAP, timeStampXAP); }
</script>
<%@ OutputCache Duration="1" VaryByParam="None" Location="None" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
form {
height: 100%;
}
#host {
height: 100%;
text-align:center;
}
</style>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
window.onload = function()
{
document.getElementById('host').focus();
}function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\\n"; errMsg += "Code: " + iErrorCode + " \\n"; errMsg += "Category: " + errorType + " \\n"; errMsg += "Message: " + args.ErrorMessage + " \\n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \\n"; errMsg += "Line: " + args.lineNumber + " \\n"; errMsg += "Position: " + args.charPosition + " \\n"; }
Hi. A nice idea. But it did not work for me. I use the divelement tools where I can display HTML content. And the content of this divelement controls stopps working by using your methode and does a refresh of the whole page.