Answer the question
In order to leave comments, you need to log in
How to access resources from a dll class library in C#?
Hello! I haven't been able to figure it out since last night. Created a WinFroms application, then added an empty resource file to the project. I added a picture to the resource file and I get the picture while the application is running like this: pictureBox1.Image = Resource1.TestImage;
But if you create a class library, then ide does not see the Resource1.resx file. Tried like this: global::library
but the ide shows that the project only has the "MyClass" class.
Why do I need it? I am writing a plugin-enabled program. From the plugin (dll), in addition to methods, images are also exported (to add buttons to the toolbar in the main program). I used to do this (in a plugin):
public Image SetToolBarIcon()
{
return Image.FromFile("image.jpg");
}
Answer the question
In order to leave comments, you need to log in
or add the attribute InternalsVisibleToAttribute
to the Library for the assembly .
or make the Resource1 resource class public, to do this, change the Custom Tool from ResXFileCodeGenerator to PublicResXFileCodeGenerator in the file properties.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question