Bug 56821 - Static ctor of MarshalByRefObject runs in primary AppDomain
Summary: Static ctor of MarshalByRefObject runs in primary AppDomain
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-05-25 00:14 UTC by Kirill Osenkov
Modified: 2017-06-02 15:58 UTC (History)
3 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Kirill Osenkov 2017-05-25 00:14:02 UTC
I'm using Mono on Windows.

Consider this C# program:
using System;

class Program
    static void Main(string[] args)
        var appDomain = AppDomain.CreateDomain("Test Domain", null, AppDomain.CurrentDomain.SetupInformation);
        var driver = (Remote)appDomain.CreateInstanceAndUnwrap(

class Remote : MarshalByRefObject
    static Remote()
        Console.WriteLine($"cctor in AppDomain {AppDomain.CurrentDomain.FriendlyName}");

    internal void Test()


If you compile and run this C# file on .NET Framework, the output is:

cctor in AppDomain Test Domain

If you run it on Mono, the output is:

cctor in AppDomain Test Domain
cctor in AppDomain CrashMono.exe

Not sure if this behavior is by design, but I thought I'd check just in case. Why is the cctor not running in the primary appdomain for .NET Framework but is running on Mono?

I'm noticing another discrepancy, not sure if related:

Assembly.Load("System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"); loads three assemblies on .NET (System.Windows.Forms, System and System.Drawing) but only one assembly on Mono (System.Windows.Forms)
Comment 1 Zoltan Varga 2017-05-30 20:58:51 UTC
Comment 2 Zoltan Varga 2017-06-02 15:58:07 UTC
Fixed in master/2017-04.

Note You need to log in before you can comment on or make changes to this bug.