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

  • Home
  • SEARCH
  • 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 938215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:36:21+00:00 2026-05-15T21:36:21+00:00

I have this code to load a config file and read all the values

  • 0

I have this code to load a config file and read all the values and it works fine when running the application but of course fails on team city because the appdomain’s base directory is where the build script (psake) is started. I know I can change directory to the build dir before executing the tests but I thought it’s better to make loading the config file work at all times regardless.

XDocument.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, cfgFile));

Is there another way to get the “BaseDirectory” that really works all times? I tried the below as well with same results:

string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
XDocument.Load(Path.Combine(path, cfgFile));

EDIT 1 The problem is the following. My solutions base directory is “C:\Project”, all compiled files are copied to “C:\Project\build”. Now in the psake build script I have the following code:

task Test -depends PrepareTests {
    try { 
        #$old = pwd
        #cd $build_dir
        &$mspec $mspec_projects --teamcity
        #cd $old
    }
    catch {
        &echo "Error starting test runner"
        Exit 1;
    }      
}

As you can see I commented out the changing of directories which makes the BaseDirectory the location of the build file / solution instead of the build directory regardless of how I try to access it. Kind of confusing if you ask me.

UPDATE I really like to know if it is possible to get the directory of the assembly regardless of what directory the application that started the app domain is located. How?

  • 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-15T21:36:22+00:00Added an answer on May 15, 2026 at 9:36 pm
    string origAssemblyLocation = Assembly.GetExecutingAssembly().CodeBase;
    

    Per MSDN:

    Assembly.CodeBase Property

    Gets the location of the assembly as
    specified originally

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's a lot of options (haaaa...) A standard one is… May 16, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer Accordng to the docs the text_content method: Returns the text… May 16, 2026 at 8:59 am
  • Editorial Team
    Editorial Team added an answer Regexp.new(Regexp.quote('http://www.microsoft.com/')) Regexp.quote simply escapes any characters that have special regexp… May 16, 2026 at 8:59 am

Trending Tags

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

Top Members

Related Questions

Okay, so I'm using perl to read in a file that contains some general
I have written a Flex Library project - a .swc file - which is
I have a Windows application which has a browser in it. The Windows application
Trying to read into an object the following XML file (can be changed) into
All examples of fluent nhibernate make such(or similar) call: c.AddMappingsFromAssembly(typeof(Product).Assembly); I don't want tu
I've recently got a new Mac laptop and am running VS2010 in a Parallels
I currently have an asp.net website hosted on two web servers that sit behind
I have a assembly made in another project (projA). Now I want to import
So we're having some issues deploying an ASP.NET MVC app to a client site.

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.