The XAP file not exist in Temporary Internet Files - silverlight

When the Silverlight application is loaded , I expect that Xap file should be in Temporary Internet Files, but can not find it, how can I make sure that my default path and do I have any setting to change this path and is it possible to run silverlight application without Xap file. I mean the Framework loads the Xap file in memory and stores the Xap file in Temporary Internet Files for future use ?

For in-browser applications the plugin relies on the browser's cache ("temporary internet files" in the case of internet explorer). For out-of-browser applications the xap will be stored in a file called application.xap in .../AppData/Local/Microsoft/Silverlight/OutOfBrowser/. or similar.
I'm not sure why you couldn't find it in IE's cache. I clearly see xaps cached in Chrome which is what I mostly use.

Related

Silverlight fails to fetch resource assemblies

We use the .NET resource manager to localize our Silverlight application and want to embed the satellite assemblies for the german language ("de") into the XAP file. Therefor, we set the neutral language to "en" and added "de" to the list of supported languages in the csproj file. This works fine, when we build the project locally. If we build the Silverlight solution with MSBuild (TFS), Silverlight will try to fetch the satellite assemblies with HTTP requests from /ClientBin/de/*.dll instead of taking those files embeded into the XAP (which do exist). Because the webserver returns 404 error codes for the non existent files, Silverlight crashes with an initialization error.
It turned out that if we remove a custom TFS build activity manipulating the assembly info code files, the Silverlight applications works as expected. Strangely, after re-enabling the activity the compiled XAP application still works (verified for two different build definitions working on seperate branches). The custom activity manipulates the assembly attributes AssemblyConfiguration, AssemblyCompany, AssemblyProduct, AssemblyCopyright, AssemblyTrademark, AssemblyVersion, and AssemblyFileVersion.
Some additional hints:
The custom activity will change the assembly info files before any compilation is done
Compiling the manipulated sources with Visual Studio will build a working XAP
The content of the XAP files (working and not working) is equal (nearly same sizes, no difference in manifest file)
The resource manager is instantiated using ResourceManager("Resource", Assembly.GetExecutingAssembly())
My questions are:
Why does Silverlight try to fetch those satellite assemblies from /ClientBin/de/ instead of just using those in the XAP file?
What kind of attribute in the assembly info file could cause such a behavior?
Why does re-enabling the versioning activity not break the XAP again?
And here's the solution: We use a tool named "Total Commander" for editing a file in the generated XAP to adjust the URL the (generic) client connects to. Since we added the localization dlls, editing the XAP with the Total Commander will lead to the behavior described above. If we manipulate the XAP with WinRAR or the internal Windows archive manager, all works as expected.
Edit: After comparing the XAP files we found, that Total Commander uses the backslash (\) to seperate directories, whereas WinRAR and the Silverlight Tools use slashes (/). It seems that we discovered a hidden Silverlight feature here ;-)

Reg Silverlight XAP location

Where on the client side will all the XAP files will be downloaded to and used by the Silverlight runtime?
The are downloaded to a temp internet folder (like other internet content). You should not need to know/care as all access is via relative path or assembly references.

Reducing .XAP file size?

I created a customized version of the Silverlight Player. After building/compiling, the .XAP which gets pushed out, it ends up being over 700KB.
I'm not too sure why it's doing this because I'm not adding any new resources. All my changes have all been in the code.
Is there any way to reduce the file size?
You are probably including DLLs you did not intend to. The Copy Local option for DLL references you add is True by default.
A XAP file is just a ZIP file with a different extension so the first thing to do is unzip it and take a look at what is included.
You can use a better Zip program to recompress the XAP file, but that will only gain you another 10%-20% at best.
If it turns out you are really just concerned about initial load time vs. total load time you can load an initial (small) bootstrapper to update the display while loading subsequent modules dynamically (look at PRISM and MEF).
You can check the "Reduce XAP size by using application library caching" option.
By default any system dlls that your application uses will be included in the XAP file. By checking this option they are downloaded as separate zip files.
This won't reduce the total size of the files that your application downloads, but will mean that when you publish an update your users won't have to download all the system dlls again - they'll already have these in their local cache.
This option is primarily used in applications that are split across several XAP files to ensure that only one copy of the system dlls are downloaded for the whole application.

How to optimize the size of silverlight XAP file by removing common files?

I have bunch of common thrid party dlls that I use in multiple silver light projects. Each produce its own XAP files with same copy of the thrid party dlls. I would like to know, is it possibl to seperate the common thrid party dlls out and load only if the local cache dll is different from the common dll used by some other XAP that was previously loaded?
In other words, what I was thinking is, first time when I enter a new silverlight page, it would load the application XAp and the Common XAP file, from that silverlight app, I go to another silverlight page, which in turn loads another XAP but this time, it will not load the common dll XAP since it was already loaded by the first XAP load.
Thanks,
If the third-party DLL's are well done, they'll come with an .extmap.xml file that allows for precisely this scenario. But you need to turn it on by checking the "Reduce XAP size by using application library caching" option in your Silverlight project(s). See http://msdn.microsoft.com/en-us/library/dd833069(VS.95).aspx for more details about how this works.
I think a more optimal solution would be to try to minify your XAP/Zip files using something like ComponentOne XAPOptimizer. The problem with your approach is that you are introducing dependencies between projects that in no way could be managed if one or more projects change. This is a good resource for strategies to lower XAP file size.
I believe that you have a main XAP which makes the calls to load the others XAPs, right?
All you have to do is, in the properties of each DLL, change the atribute "Copy to Local" to FALSE, except on your main XAP.
When the user download the main XAP, the DLL will be available to all dependents XAP.

.XAP file formed only once?

I am developing some application project in Silverlight using deep zoom.I copy my images under ClientBin/Source .However I notice that the associated .xap file is formed only once? I change the code and re-run but still see that there is no modification in the .xap file.Why does this happen?
Copying files to the ClientBin folder is a modification to the associated web project not to the silverlight project. The MSBuild code detects that none of the files that make up the content of the XAP file has changed and hence doesn't bother to rebuild something which would turn out have exactly the same as the last build.

Resources