[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

C#: Class Library

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.
0
Mister_Spock
Asked:
Mister_Spock
  • 2
  • 2
1 Solution
 
oferamCommented:
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
0
 
Mister_SpockAuthor Commented:
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.
0
 
Mister_SpockAuthor Commented:
I delete and re-word
0
 
oferamCommented:
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?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now