Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's difference between the two build actions "Resource" and "Embedded Resource" in Visual Studio 2010?

I have read the following article which supposed to explain it, but it does not help me:

http://msdn.microsoft.com/en-us/library/ht9h2dk8(VS.80).aspx

My case is that I would like to have a dll which contains hundreds of icons. And the icons dll will be shared and used in various applications. Obviously, I would not like all those icons to be loaded in memory if one application just use tens of them. So I'm interested to know if "Resource" (the build action) would allow me to load icons on demand instead of loading all at once.

Could anyone help?

like image 253
Simoscofield Avatar asked Nov 07 '11 11:11

Simoscofield


1 Answers

I'm no where near Visual Studio at the moment, so I can't test this out directly, but I'll attempt to help blind.

For starters, if you place all of your resources in a Zip file loaded added to your project as Content they won't be loaded by the application until you call them. This is a great way to manage resources if you're going to shove a large number of files in, as you mentioned.

Take a look at Jeff Wilcox' blog regarding using a dynamically loaded about page for more information.

You can also take a look at MSDN which details using GetResourceStream to load files from Zip files dynamically.

Of course, depending on how many files you plan on using it may be a far better option to find a way to segment out the files needed by the application at compile time. As there is an overhead cost to pulling a file in as a resource, irrespective of the method used.

like image 195
Frazell Thomas Avatar answered Sep 28 '22 21:09

Frazell Thomas