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 3310158
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:43:34+00:00 2026-05-17T21:43:34+00:00

i created a appDomain in my application which base directory is different to my

  • 0

i created a appDomain in my application which base directory is different to my application directory, but it is under the application. i loaded an assembly in the created domain and create object instance from that domain. then i try to execute the method of the object. but i observe an odd behavior.

    public class Class1 : MarshalByRefObject
{
    public void action()
    {
        Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
        TextReader sr = new StreamReader(File.OpenRead(AppDomain.CurrentDomain.BaseDirectory + "\\test.txt"));

        Console.WriteLine(sr.ReadToEnd());
    }
}

there’s a ‘test.txt’ file under the appDomain.BaseDirectory. but if i only give the file name, the application still try to search the file from the application execution directory and failed to find the file.

how can i make sure the code executed in another domain is using the base directory as the default search path.

  • 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-17T21:43:34+00:00Added an answer on May 17, 2026 at 9:43 pm

    The current directory of the process as maintained by Windows (Environment.CurrentDirectory) is not affected by the AppDomainSetup. It only affects where the CLR will look for assemblies. Changing CurrentDirectory will change it process-wide, surely that’s not what you want.

    Work with full path names, like you do in your snippet.

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

Sidebar

Related Questions

I have created a c# 2.0 WinForm application which loads dlls, searches for an
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created a simple .NET windows application in Visual Studio 2005 and on just
I created a Rails application normally. Then created the scaffold for an event class.
I have a winforms project which allows future developers to create plugins for the
I have created a class library called AddServiceLibrary in which I have a method
I have an application which uses SqlConnection.ClearAllPools to close all connections before dropping a
I have created these functions which I described in the question. However I think
I'm trying to create a sandboxed AppDomain for loading extensions/plugins. I have a MarshalByRefObject
I notice in several API's, that you may create a struct which is used

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.