VS .NET and Images - Solved
After having a conversation with Jamie, we were able to figure out a way to get the project directory at runtime. I've updated the code example (I even updated the class names - I was so happy!) - it basically comes down to doing three things. First, get the location of the assembly in the constructor for a default directory value.
Assembly targetAssembly = (Assembly.GetEntryAssembly() != null ?
Assembly.GetEntryAssembly() : Assembly.GetCallingAssembly());
Next, override the
Site property to determine if the control is in design-mode and, if it is, get the location of the project through the DTE:
public override ISite Site
base.Site = value;
if(base.Site != null)
ProjectItem projectItem =
if(projectItem != null)
OnLoad() and load the image there:
protected override void OnLoad(EventArgs e)
this.drumPictureBox.Image = Image.FromFile(
this.locationLabel.Text = this.loadingDirectory;
That's essentially it. Thanks again to Jamie for helping me out on this.
* Posted at 02.01.2005 10:46:02 PM CST | Link *