C#: Class Library

Posted on 2009-12-17
Last Modified: 2013-12-17
I have a class library that is calling a XML file with System.Xml.XmlReader. I have the DLL referenced into a console application. The problem is, the DLL is trying to access a XML file that was added to the Class Library before it was compiled. Since the DLL is now part of the console application, it is unable to find the XML file. I am doing this to avoid re-writing or copy \ paste into the console application. Is there a way to include the XML file into a Class Library before building into a DLL? I hope this is making sense, not sure what to ask.
Question by:Mister_Spock
    LVL 6

    Expert Comment

    Can you explain the situation a bit more?

    You have a console application that uses a DLL to access an XML file.
    The DLL is trying to read information from the XNML file and fail?
    Are you sure the DLL "finds" the XML file, maybe you have a wrong path?

    Can you explain a bit more what you are trying to achieve, and maybe I can propose another solution
    LVL 3

    Author Comment

    My firm uses the administrator account for various automation programs. I want to be able to check not only the current administrator password, but the last two. The reason is we change the administrator password once every three months. Also if someone from the I.T. department leaves the company for any reason, it has to be changed ASAP. The laptops may not have gotten the current administrator password through SMS for some reason and still have the previous password. I want to be able to start the program if the user has the current administrator password or one of the previous two.

    I wrote a XML file that keeps the passwords, it has to be manually updated each time it is used to reflect the new password. The way we have it now is the administrator password has to be updated in each program that checks the password. I want to be able to reference the DLL and use an XML file with it. The trouble is, the XMLReader is looking in the assembly of the console application, not the DLL itself. I need to know if there is a way to embed a XML file in a DLL so when you reference it in another project, it uses the XML file embedded in the DLL. Otherwise I would have to add an XML file to each program the DLL is referenced in, that defeats the purpose of re-using code.
    LVL 3

    Author Comment

    I delete and re-word
    LVL 6

    Accepted Solution

    An XML file is just an input file with no logic. I have a feeling that you are embedding this XML file as a resource, is that correct?
    Why don't you use the XML file as a FILE outside of your DLL and console application and read it from the file system?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( 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…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now