Solved

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

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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