C# Help to Load External DLL PNG Sources

Asked

Viewed 378 times

1

I created the Dll of Sources with IPNG magens in C# when I compile to read in PictureBox of Visual Studio I receive the news of NUll or of missing System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

inserir a descrição da imagem aqui

Assembly asm = Assembly.LoadFrom(System.Environment.CurrentDirectory +@"\PNGRES.dll");
Stream strm = asm.GetManifestResourceStream("resources.PNG"+(string)asm.GetManifestResourceNames()[102]);
Bitmap b = (Bitmap)Image.FromStream(strm);
pictureBox1.Image = b;
  • Friend you have to give more details about your question/question. What mistake are you making? Are you going to upload this image where? from where??? Are you doing this where?? GIVE DETAILS.

  • Hello, Carlos, and welcome! I believe that your content is actually an example of a solution rather than a question, correct? You can post a question (which will help developers in the future find this post) and answer it yourself.

  • Welcome to Stack Overflow! For the community to help you, it’s important to explain your problem in detail. I suggest you read the articles: Tour and how to ask a question.

1 answer

1

The code is a little different from yours, but, this form should be revised, it is very simple when we add the reference in the project, but, I made an example dynamically loading the dll.

To library is called: Biblioteca.dll, the Resource (filing cabinet .resx) is called: Imagens.resx, the name to put it on builder of class ResourceManager is Biblioteca.Imagens, as it is in the code. Inside this Resource has 3 images with their names: _1, _2 and _3 which in this case is the value of GetObject.

Having that value (Object), make a cast (Imagem) and pass the value to PictureBox1.Image that the image will be loaded ...

string path = @"C:\Projetos\";
string real = System.IO.Path.Combine(path, @"Biblioteca.dll");

Assembly assembly = Assembly.LoadFrom(real);
ResourceManager resourceManager = new ResourceManager("Biblioteca.Imagens", assembly);
pictureBox1.Image = (Image)resourceManager.GetObject("_3");

Main reference of the code

Browser other questions tagged

You are not signed in. Login or sign up in order to post.