Windows Phone 7: Content vs. Resource Build Action

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When working with media files like images or video on Windows Phone Silverlight there are two significant build options: Build Action = Content and Build Action = Resource.
File setup for build action Content as shown below will not be included in the assembly.

image

As you see the image Background.Jpg is not a part of assembly.

image

But if you dig into XAP file you you will see that the picture is there. We say embedded as “content”.

image

Media content contained in XAP file is usually loaded in application from file stream, means as a file.

if you set the build action on Resource the image is embedded in the assembly.

image

Now take a look into XAP file and you will see that image Background.jpg is no more there:

image

When one image is loaded in the application as resource all data are streamed in memory.

Build-Action Impact on Performance

Most developers are surprised to hear that performance of one application can be increased if the footprint of application is decreased. There are many reasons for this, which are out of scope in this post. However this statement holds for Windows Phone too. Performance of an application on Windows

Assuming that we should anyhow achieve small footprint to save the memory one reason is signature verification process.  For verification purposes, application assemblies are signed and then signature is checked every time an application starts up.  The amount of time this operation takes scales directly with the size of assemblies. The final version of Windows Phone 7 will have a cache of these signature checks and so the impact of this will be smaller. But the first time an application launches the verification will be performed. 

Another reason to use Content-Build action is optimization of the media pipeline on the Windows Phone 7. The WP7 operating system is optimized to use files and network streams, but not in-memory streams.  This means that any media files included as resource will perform worst than medias build as content.  Files build as content content will included in  in the .XAP and NOT in assembly. 

Note that playback of media files included as a Resource inside a DLL will be first copied to a file on the phone and then played back. 


Posted Sep 18 2010, 11:26 PM by Damir Dobric

Comments

cheap wedding dresses wrote re: Windows Phone 7: Content vs. Resource Build Action
on 08-24-2012 10:23

good

developers.de is a .Net Community Blog powered by daenet GmbH.