I have a usercontrol that I have designed which has a picturebox on it. I want the image for the picturebox to come from a separate dll in my project where I store my images. I can manually go into the Designer.cs and set this.pictureBox1.Image = global::(Name of my dll).Properties.Resources.imageName; which produces the effect I want. The difficulty is that whenever I do something that causes the Designer.cs to regenerate, Visual studio insists on going and getting that image and serializing it to the control's resx file, then it replaces the reference with this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));.
I have tried working with the DesignerSerializationVisibility and its three settings. All I seem to be able to do with that is prevent Visual Studio from including the Image property at all, which causes my control to malfunction at run time.
I've looked into designing a custom CodeDomSerializer but I've not had any success with that at this point.
Is there any way to just tell Visual Studio to leave that property as it is and don't change it?
For those who have kindly taken the time to consider this item or who may visit this in the future, I have discovered the resolution. Someone prior to me had set this up, so I was unaware of what they had done.
So, the goal was to have a dll that contained images, and when/if those images changed, you could just swap out the dll and the various controls in the other projects would automatically pick up those changes at runtime by simply replacing that single dll.
The method requires setting up a project with nothing but the image resources. Then link (not copy) the resx file from that project to the other ones that are using it. Then, once you put the
global::references in the Designer.cs, they will stay in there unmolested by Visual Studio.