Solved

Visual Studio 2008 form ICON cannot be accessed as a common resource

Posted on 2014-04-28
3
436 Views
Last Modified: 2014-04-28
Hi,

I am working on a corporate image update for our applications.  The old ico file was a very old one and it was only 1KB in size (was only one size at 32x32).  I was given a much more modern ico file that supports 6 different resolutions.  This new ico file is 362KB in size.  After incorporating this new ico file into my project, (changing it in Project Properties->Application->Icon (which seems to be a pointless exercise)) and also changing it in every form I have (about 15), my compiled exe size grew from about 700K to 6M, almost a 10 fold increase in size.

It seems that the way Visual Studio 2008 references an ico file is to incorporate a copy of the whole image right into each and every form in the project instead of referencing one common ico for the whole project.

Is there a work around for this to simply use one single ico reference for all forms.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40028213
Insert the icon as a resource in the application itself, and set it to the forms in the Form_Load event.

To insert it in the application resources, open the project's Properties window and it's Resources tab.

Select Icons in the upper left corner of the window.

Then, under Add Resource, go to Add Existing File to select your icon.

A right click will enable you to give if a better name is the one coming from the file is not very good. That name will be used in code to reference the icon.

Now, in the Form_Load event of all your forms, add a line like the following:

Me.Icon=My.Resources.YourIconName

Et voilà
0
 

Author Closing Comment

by:RobertFromSecretWeapons
ID: 40028425
That is very clever.  WOW. I guess I can't think out of the box today. Works great.
The only remaining issue I will have to test for is to see if a proper desktop icon is found during the creation of a desktop shortcut icon rather than the little placeholder icon that all the forms now have.

I assume this issue should be properly addressed by the application icon that gets initialized in the project->project properties->application->Icon setting for the windows form project.
0
 
LVL 40
ID: 40028619
Unfortunately, I do not know a way to set a resource to the application. I have searched for ways to do it both ways. Either set the forms icon to the one defined for the application, or set the application icon to the resource. Unfortunately, I never found an answer. The application icon seems to be defined in the application manifest instead of the resources.

So as far as I know, the application icon must be defined separately from the resource.

What you can do however if you want to minimize space, is to make a copy of your icon file, open the copy in Visual Studio, and delete the resolutions that are not needed for a desktop icon. The different resolutions available are listed at the left side of the editor, and you can delete those you do not need. Then reference that copy for the application icon.

On the other side, if you will not be using the icons in the resource for anything else than the forms icon, you might want to make a copy of the file, remove the resolutions that are not used for the forms, and use that instead in your resources.

You might have to make a few tests in different environments to see which resolutions are never used for the desktop icon and which are never used for the forms icons.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question