I'm trying to use a single .ico
file (with multiple sizes) for both the Application executable and a form inside the application, without including the icon in the executable twice.
I noticed this because my app (without icons) is 600KB compiled, and the icon is 300KB, but when I use both the app increases to 1200KB compiled, indicating it's being embedded twice.
Here's what I've tried:
MyIcon.ico
file.
MyIcon.ico
file.
MyIcon.ico
filethis.Icon = Properties.Resources.MyIcon;
Resources\MyIcon.ico
(which is listed in the drop-down)
Clearly, it's still including the file a second time, not referencing an embedded resource.
MyIcon.ico
file.
this.Icon = Icon.ExtractAssociatedIcon(AppDomain.CurrentDomain.FriendlyName);
Before I go deeper into this, am I missing something obvious? Is there a standard way to do this? Am I just not using Icon.ExtractAssociatedIcon()
properly?
I'm sorry, this is my oversight. Method (3) does actually work.
I was running this from the VisualStudio debugger, but didn't notice the .vshost.exe
file gets a different icon -- which is what was showing up in the form.
When the compiled exe is used directly, it works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With