locked
setting the app icon in the project settings? RRS feed

  • Question

  • how does this work exactly?

    if i set the icon to an icon in a project with resources i can get the icon with Assembly.GetExecutingAssembly

    but i dont see it in the resources and the icon itself is not an embedded resource...

    and if i set the icon to an icon in a project without a resx file i cannot get the icon at runtime with Assembly.GetExecutingAssembly().GetManifestResourceStream

    the icon of the executable is still set when i have no resx file... is it possible to get this icon at runtime somehow?

    thanks
    • Changed type Chao Kuo Thursday, October 22, 2009 11:54 AM
    • Changed type RakkaRage Thursday, October 22, 2009 12:20 PM
    Thursday, October 15, 2009 7:41 PM

Answers

  • Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location);

    will load the icon embedded with /win32icon or project settings, as opposed to an embedded resource
    • Marked as answer by RakkaRage Thursday, October 22, 2009 12:20 PM
    Thursday, October 22, 2009 12:20 PM

All replies

  • what i mean is that setting the icon property seems to embed the icon into the executable without the need for a resource file etc or whatever... that icon is only used as the file icon not the window icon? how can i load that icon to the form.icon in form load? does that make sense?
    • Marked as answer by RakkaRage Thursday, October 22, 2009 12:20 PM
    • Unmarked as answer by RakkaRage Thursday, October 22, 2009 12:20 PM
    Thursday, October 15, 2009 8:42 PM
  • must i embed a copy of the icon in the project as well? even though i already set it in project settings? it wont be embedded twice? i guess not? the embed just makes it accessable through the manifest? idk
    Thursday, October 15, 2009 8:45 PM
  • I dont bother embedding an icon, I just load it at runtime.

     

    try

    {

     

    this.Icon = BitmapFrame.Create(

     

    new Uri(@"c:\PCBCAD30\PCBCAD30.ico", UriKind.Relative));

    }

     

    catch

    {

    System.Windows.

    MessageBox.Show("Cant load Icon.");

    };

    • Proposed as answer by Harry Zhu Wednesday, October 21, 2009 3:45 AM
    • Unproposed as answer by Harry Zhu Wednesday, October 21, 2009 3:46 AM
    Thursday, October 15, 2009 8:58 PM
  • We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Thank you!
    Chao

    Thursday, October 22, 2009 11:53 AM
  • Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location);

    will load the icon embedded with /win32icon or project settings, as opposed to an embedded resource
    • Marked as answer by RakkaRage Thursday, October 22, 2009 12:20 PM
    Thursday, October 22, 2009 12:20 PM