Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 724197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:11:40+00:00 2026-05-14T06:11:40+00:00

Scenario I have a windows service written in C# that performs some processing based

  • 0

Scenario

I have a windows service written in C# that performs some processing based on parsing an XML file and use that data to carry out various tasks.
The service also does various bits of logging – which uses settings from an APP.Config file.

The Problem

When the service is compiled, installed and run, the XML file seems to disappear. I’m getting the impression that it is just ignored or something like that.

So far

I’ve tried using TWO App.Config files, one named App.Config that contains settings for the service, and the other called MyService.exe.config that contains all of the data that was used in the XML file (the idea being that I can parse the XML from a config file that actually gets compiled and appears in my installation directory.

However

When I do this, all that happens is that ONE config file appears (with the name MyService.exe.config), but it contains the contents of the App.Config file and not the XML data that I want to parse.

What I need

All I want is to have a config file for my settings, and an XML file for my data.

Question

Is this possible?
I know the application works as it was originally built as a console application that ran fine.

Other

The application has to be designed this way (as in, I need my data stored as XML, and my settings stored in a config file).

Thoughts

If I could somehow combine the contents of the two files into ONE config file, that would be one way of solving the problem. However, I have tried this and of course I get a “Type Initialisation Exception”, as the config file cannot interprate the XML data (probably because the tags are custom and do not form any part of the config schema – or something like that).

Ideas

Please could someone explain to me if it is possible for me to have an XML file AND a config file that will actually be compiled and stored in my installation directory for the service when it is run?

CODE

Custom XML/Data Config File

   <?xml version="1.0" encoding="utf-8" ?> 
  <configuration> 
  <servers> 
<SV066930> 
  <add name="Name" value = "SV066930" /> 
  <processes> 
<SimonTest1> 
  <add name="ProcessName" value="notepad.exe" /> 
  <add name="CommandLine" value="C:\\WINDOWS\\system32\\notepad.exe    C:\\WINDOWS\\Profiles\\TA2TOF1\\Desktop\\SimonTest1.txt" /> 
          </SimonTest1> 
 </processes> 
  </SV066930> 
  </servers> 
 </configuration> 

APP.Config Settings File

   <?xml version="1.0" encoding="utf-8" ?> 
  <configuration> 
   <configSections> 
     <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxx" /> 
   </configSections> 
  <connectionStrings> 
 <add name="DB" connectionString="Data Source=etc......" /> 
  </connectionStrings> 
  </configuration> 

Help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:11:41+00:00Added an answer on May 14, 2026 at 6:11 am

    You haven’t said what the build action for your XML file is. You can either make it Content, in which case it should be copied to the output directory, or you could make it an Embedded Resource, in which case it will be embedded within your assembly.

    If you don’t need to change it after the build, I’d go for the Embedded Resource approach – it means that you don’t have another file to worry about. However, it’s less flexible as you can’t change the file afterwards. For this option, you’d use Assembly.GetManifestResourceStream to load the XML file at execution time.

    If you go for the Content approach, be aware that the current directory of your process may not be the one containing your assembly – you can use

    string module = typeof(YourService).Assembly.GetModules()[0].FullyQualifiedName;
    string directory = Path.GetDirectoryName(module);
    

    to find the directory, and then load the file relative to that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 373k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure I understand your question :-? but I… May 14, 2026 at 7:44 pm
  • Editorial Team
    Editorial Team added an answer I guess that the following would be a good starting… May 14, 2026 at 7:44 pm
  • Editorial Team
    Editorial Team added an answer To me, it sounds like problem with memory. Could happen… May 14, 2026 at 7:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.