Question

I am trying to develop a windows form application which works ok so far. I have 4 app.config files and i configure everything properly.

My problem comes when i try to get the key for the notification icon.

I always get a message that it cannot convert string to Drawing.Icon. Can anyone gimme a hint on this, please?

App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="customer" value="Customer" />
    <add key="link" value="http://link.i.need" />
    <add key="icopath" value="Properties.Resources.firstlogo" />
  </appSettings>
</configuration> 

form that functions OK:

private void formresize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                ShowInTaskbar = true;
                notification.Visible = true;
                notification.BalloonTipText = "running in background...";
                **System.Drawing.Icon ico = Properties.Resources.firstlogo;**
                notification.Icon = ico;
                notification.ShowBalloonTip(1000);
            }
        }

form that does not:

private void formresize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                ShowInTaskbar = true;
                notification.Visible = true;
                notification.BalloonTipText = "running in background...";
                **System.Drawing.Icon ico = ConfigurationManager.AppSettings["icopath"].ToString();**
                notification.Icon = ico;
                notification.ShowBalloonTip(1000);
            }
        }

Thank you.

Was it helpful?

Solution

Try this:

System.Drawing.Icon ico = (System.Drawing.Icon)Properties.Resources.ResourceManager.GetObject(ConfigurationManager.AppSettings["icopath"].ToString());

Thanks, Eric

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top