Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

How to load over 40 dll files into C# application.

Hi
I have a little problem with dll files.
My application requires over 40 dll, which contain images for Windows Forms, and I just wonder what is the best way to load these dll into application. Problem is that dll files are stored in different subfolders of main application; I want to call it dynamically when I need it.

Could anyone tell me how to do it and how to access images from dll files?
I will appreciate sample code!!
0
knobloch
Asked:
knobloch
  • 2
  • 2
1 Solution
 
gregoryyoungCommented:
you would use the Assembly object to open the .dll the use  Assembly.GetManifestResourceStream("namespace." + strIdentifier)); to get the embedded resource

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemReflectionAssemblyClassGetManifestResourceStreamTopic2.asp

you would then use Image.FromStream() to load an image from the resource strem.
0
 
knoblochAuthor Commented:
Could you write a sample code for me?
How can I access for example "image1.gif" from ../mySubfolder/myFile.dll ?

Thanks
0
 
gregoryyoungCommented:
Assemblt foo = Assembly.LoadFrom(path);
Stream stream = foo.GetManifestResourceStream("namespace.objectname");
Image i = Image.FromStream(stream);
0
 
knoblochAuthor Commented:
Thanks
That’s good enough for me.

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now