.XAP file formed only once? - silverlight

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.

Related

How to import files from computer?

I have been making a simple program on my computer using Dr. Java, and I would like to know how to move it to my android on AIDE. I can easily get the files onto the android, I just can't figure out how to make AIDE compile and run them.
Thanks!
Using My Files or the file browser you prefer, move your entire project directory into a folder call AppProjects. Should be fairly easy to open from there. Also you will want to make sure the directory is set up correctly. If all else fails, you can always recreate the project using AIDE and copy your java files into the java folder and XML files into the layout folder, and your images and icons into the drawable folders. These folders are automatically generated by AIDE so you don't have to create them.
You can copy the source files normally as you do with other files but Desktop's Java is not always same as Android's. So it needs some more coding and editing to make the code work as you want. But if the code is so simple, it can work.

Reduce XAP size by using application library caching setting causes warnings on missing files in ClientBin

When I enable the 'Reduce XAP size by using application library caching' setting on a project in Silverlight, I am finding that certain files are missing from my ClientBin folder and now show up in Visual Studio's solution explorer with the warning icon on them, such as System.Xml.Linq.zip and System.ServiceModel.DomainServices.Client.Web.zip. The vast majority of files copy however and have no warnings. I'm wondering if someone knows how to fix this? If I enable this setting, the missing files copy into ClientBin just fine. I'm assuming that they reason they are missing with the setting disabled is that they are contained within the XAP file, but then why is it still expecting them to be in the ClientBin and giving me the warning indicator icon.
In the Properties Section of the files with the warning icon, check the Copy to Output Directory field. Change it to Copy Always. These are those references that you externally add to your project hence the inclusion in ClientBin is necessary. Also check the physical presence of the files in the directory.

.Xap download if there is any change in version of .xap file

I am using MEF in Silverlight for dynamic download .xap file. I want to download .xap file only one time and then I want to download .xap file only when if there is any change in version of .xap file.
What you describe is normal behaviour. The .xap file will only be downloaded if:
There is a change in the .xap file at the server.
The user clears their cache and so no longer has the file on their machine any more.
We have seen cases where the .xap file isn't downloaded when there has been a change.
What are you seeing that makes you think the .xap file is being downloaded each time?
The last accessed time in your cache merely shows the time the application was last run, not the time the .xap file was last downloaded.

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 ;-)

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.

Resources