0

I am creating a windows Form app in C# using .NET framework 4.8.

I'm encountering issues with the icon, i've already added the icon as a ressource (and defined as an Embedded Ressource), but, require doesn't work, i'm still having the Wow from default logo.

How do i require the ressource correctly? (and getting MY icon?)

My code below:

static void Main(string[] args)
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Form1 form = new Form1(new Installer()); //Nothing exciting, callig constructor of Form1
    form.Icon = WindowsFormsApp1.Properties.Resources.icon; //The tricky line
    form.TopMost = true; //Some more config
    form.FormBorderStyle = FormBorderStyle.FixedSingle;
    form.MaximizeBox = false;
    Application.Run(form); //Init Form
}

#######################EDIT

I've replaced my main's body by the code below and the issue still there

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form1 form = new Form1(new Installer());
var exe = System.Reflection.Assembly.GetExecutingAssembly();
Stream iconStream=exe.GetManifestResourceStream("WindowsFormsApp1.icon.ico");
if (iconStream != null)  form.Icon = new Icon(iconStream);
form.TopMost = true;
form.FormBorderStyle = FormBorderStyle.FixedSingle;
form.MaximizeBox = false;
Application.Run(form);

0 Answers0