Solved

C# How to get the resource names embedded in a DLL file?

Posted on 2006-11-11
4
1,850 Views
Last Modified: 2008-02-01
I have .xsl file embedded in a dLL. I have added the dll as a reference in my current project.
And I want to get all the names of all files in the dll from my current project.

This is what I calling from the Main method.

When I just try to get the resource file names from the assemblies, it is not giving the proper file names. My code :

Assembly a = Assembly.GetExecutingAssembly();

 string[] resNames = a.GetManifestResourceNames();

int len = resNames.Length;

                for (int i = 0; i < len;i++ )
                {
                    MessageBox.Show("filenames == "+resNames[i]);
                }


It is giving the following output :--

WindowsApplication3.Form1.resources
WindowsApplication3.Properties.Resources.resources

It is not reading the resource names inside the dll file . Why ??

Is something worng with my code ?

thanks
0
Comment
Question by:paromitabanerjee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17923143
You have got the wrong assembly.
The xsl files are embedded in the dll and you are looking at resources in the winforms executable.
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17923154
Try :

Assembly a = Assembly.LoadFile("path_to_your_dll");
0
 

Author Comment

by:paromitabanerjee
ID: 17923250
yup. works gt8 !!

thanks.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17923308
In your dll that contains the XSL files you could define a nice simple class called XSLLibrary that has a single static method like :

public static stream GetXSL(string nameOfFile){

    // in here you can handle all the extracting of the xsl from the dll etc

}

It doesn't necessarily have to return a stream, it could return an XMLDocument, or and XslTransform, whatever is most useful.
In anycase, it would encapsulate the logic of retrieving the XSL files into a single method :

XSLLibrary.GetXSL();

If at any point in future you wanted to change how this XSL was stored or distributed (for instance you wanted to have the xsl library published on a website and the application would retrieve xsl files from there) you could just change this one method and it would be done without having to change any ofl your other code.

Just a thought....
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why use this lambda? 12 98
WPF user control poped up from a window 1 52
c#, datatable, aspx 4 53
Which is best Image Resizing Web service 11 42
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question