Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is MicroStrategy.NET? 2 47
asp.net mvc5 3 38
Pass through dll 2 38
cs.Designer Issue 2 20
Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

9 Experts available now in Live!

Get 1:1 Help Now