Search code examples
c#.netresourcesresx

.NET Custom Control Resources.resx


I have a C# custom control that loads images from Resources.resx. I was loading this resources into the Project's Resources and then accessing them like:

ProjectNamespace.Properties.Resources.resourcename;

This works for one project but now I want to use my control in multiple projects.

What's the best way to handle this? Load the resources into the controls .resx? How can I access them from there? Or should I approach this completely differently?


Solution

  • It should work as is, even if your control is used from other projects.

    The code generated by VS is a wrapper around the ResourceManager class, and it gives the assembly of your control as a constructor parameter. So, the ResourceManager always knows where to look for resources.