How do I specify a resource name for an Icon() constructor?

Feb 3 2005 7:06 PM
I have a project in which I would like to set my Form's Icon member variable to a new Icon(). The Icon which I want to set it to is in my project, and is named Icon1.ico. As I understand it, the call to do this is: this.Icon = new Icon(GetType(), "Proj1.Icon1.ico"); However, when I try to do this, I'm getting a System.ArgumentException with the additional information that "Resource 'Proj1.Icon1.ico' could not be found in class 'MyNamespace.Form1'." Now, I'm not sure why it's bringing "MyNamespace.Form1" into the picture. Maybe I'm misunderstanding, but what I think I'm supposed to do is add Icon1.ico to my Proj1.csproj file, to my list of source files in the Proj1 project. Am I supposed to do something else? Am I supposed to somehow associate that icon file with my Form1 class? Maybe that's the step that I am missing. One way or another, I don't yet understand how to create a resource name that the Icon() constructor will be happy with. Does anybody have any pointers for me? Thanks, Brian

Answers (1)