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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:56:00+00:00 2026-05-26T06:56:00+00:00

I have a situation where I need to create a (arguably dirty) soak test

  • 0

I have a situation where I need to create a (arguably dirty) soak test runner. The idea being to use something like Tasks or the ThreadPool to run a massive amount of the tests at one time.

The issue is that it will be using a lot of (poorly developed, by me) helper classes that use statics within them. This has never been an issue as everything was torn down and restarted after it was used. This means that when I start multiple threads in the same app domain, they use the same statics, and things get messy.

Note: it is an assumption based on testing I’ve been doing, I’m not 100% sure on that being the issue.

I’ve tried creating a new AppDomain (AppDomain.Create) and then created an instance of a class using it (domain.CreateInstanceFromAndUnwrap), and it creates the instance, and I can call methods on it. The problem is that it doesn’t seem to be running in the new AppDomain.

Here’s the code I have so far:

    static void CallBack(BasePerfTest bpf)
    {
        Console.WriteLine("CurrentAppDomain (WithinCallback): {0}", Thread.GetDomain().Id);
        AppDomain newdomain = AppDomain.CreateDomain(Guid.NewGuid().ToString());
        //newdomain.ExecuteAssembly(".\\PerformanceTestRunner.exe", new string[] { bpf.ToString() });
        ProcessRunner pr = (ProcessRunner)newdomain.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly().Location, "PerformanceTesting.ProcessRunner");
        pr.RunProcess(bpf);
    }

}
[Serializable]
public class ProcessRunner
{
    public void RunProcess(BasePerfTest bpf)
    {
        Console.WriteLine("CurrentAppDomain (WithinPR): {0}", Thread.GetDomain().Id);
    }

}

Now, I would expect that the RunProcess() method is executed in the domain, but the DomainID is still the same, and therefore it’s hitting the issue with the statics colliding.

Now, I did created a separate console app, and the commented out line shows the code I used to run it. This DID run in the new domain, but the question is why.

I’m happy to be pointed in the direction of some bedtime reading on how this works, I’ve ‘d for the past day and I think I must just not be using the right terms.

Any help is much appreciated.

Thanks,
Martin

  • 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-26T06:56:01+00:00Added an answer on May 26, 2026 at 6:56 am

    There are two ways to expose objects over AppDomain boundaries:

    • Serializable – serializes the object, so you get a copy.
    • MarshalByRefObject – creates a proxy to your object, using remoting.

    You need the latter for your ProcessRunner class.

    Make your class inherit from MarshalByRefObject:

    public class ProcessRunner : MarshalByRefbject
    {
        public void RunProcess(BasePerfTest bpf)
        {
            Console.WriteLine("CurrentAppDomain (WithinPR): {0}", Thread.GetDomain().Id);
        }
    }
    

    When you instantiate your class in the second AppDomain, you get a proxy. The example in the documentation for MarshalByRefObject on MSDN should also help you – it demonstrates almost exactly what you are trying to do.

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

Sidebar

Related Questions

I have a situation where I need to do something like select 2, id
I have a situation where I need to notify some users when something in
I have a situation, where I need to create a new JavaScript object that
I have a situation where I need to use some strings temporarily but I've
I have a situation where I need to create a 'master object' instance by
The situation is, that i need to create table in grid view looking like
I have a situation like when i submit the employee form i need to
I have a situation where I need to do this CREATE PROCEDURE search_sp @condition
I have a situation where I need to create some kind of uniqueness between
I have a situation where I need to use Guice 3.0 to instantiate my

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.