advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Download the code for this article
This is a cool technique. Were you aware of the capability for embedding files in .NET assemblies before reading this article? Do you already use the technique or do you plan to now? If you have any questions or problems embedding files in your .NET assemblies, let us know in the vb.dotnet.technical discussion group.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 4.2/5 | Rate this item | 6 users have rated this item.
 

How to Embed Resource Files in .NET Assemblies

Use .NET's ability to embed XML files, icons, graphics—anything you want—directly into your assemblies.  


advertisement
his article describes how to use .NET's ability to embed XML files, icons and other files in an assembly so your code can access them at run-time. Embedding the files helps you avoid problems commonly associated with external files, such as missing files, difficulty locating the files at runtime, and issues with upgrading and versioning.


The ability to embed resources in an application file is not new, but the mechanism for embedding files in .NET is different then for unmanaged code, so don't expect to be able to work with embedded resources in exactly the same way as you could in unmanaged code.

Microsoft itself frequently embeds resources in application files. For example, if you load an XML file into Internet Explorer (IE), it renders the file in a TreeView-style manner, using different colors for nodes, attributes, and text content. IE accomplishes that by using an embedded resource, an XSLT stylesheet. You can access the stylesheet using the URL res://msxml.dll/DEFAULTSS.XSL (you can type this straight into IE's address field to see the stylesheet contents).

Author note: You can't use this technique to access resources embedded within .NET assemblies, because the resource files are not stored in the same way.

  Next Page: Storing Files as Resources in an Assembly


Page 1: IntroductionPage 3: Build the Sample Application
Page 2: Storing Files as Resources in an Assembly 
Please rate this item (5=best)
 1  2  3  4  5
advertisement