Solved

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

Posted on 2006-11-11
4
1,811 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

943 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

Need Help in Real-Time?

Connect with top rated Experts

3 Experts available now in Live!

Get 1:1 Help Now