2 // MonoTests.System.Runtime.Remoting.RemotingServicesTest.cs
4 // Author: Alexis Christoforides (alchri@microsoft.com)
6 // Copyright (c) Microsoft. All rights reserved.
7 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 using System
.Reflection
;
11 using System
.Threading
.Tasks
;
12 using NUnit
.Framework
;
14 namespace MonoTests
.System
.Runtime
.Remoting
17 public class RemotingServicesTest
19 public class AppDomainObject
: MarshalByRefObject
21 public void Init(CrossDomainSerializedObject applicationDependencies
) // racy exception here
27 public class CrossDomainSerializedObject
: MarshalByRefObject
30 private static CrossDomainSerializedObject crossDomainSerializedObject
;
32 private static void AppDomainWithRemotingSerialization(Assembly assembly
, string name
)
34 var appDomain
= AppDomain
.CreateDomain(name
);
35 var appDomainObject
= (AppDomainObject
)appDomain
.CreateInstanceAndUnwrap(assembly
.GetName().Name
, typeof(AppDomainObject
).FullName
);
36 appDomainObject
.Init(crossDomainSerializedObject
);
40 public void Bug46473 () // concurrent serialization/deserialization
43 crossDomainSerializedObject
= new CrossDomainSerializedObject();
44 Task
[] tasks
= new Task
[20];
45 for (int i
= 0; i
< tasks
.Length
; i
++)
47 var assembly
= Assembly
.GetAssembly(typeof(AppDomainObject
));
48 var name
= "AppDomainWithCall" + i
;
49 tasks
[i
] = Task
.Factory
.StartNew(() => AppDomainWithRemotingSerialization(assembly
, name
));
53 } catch (AggregateException e
) {
55 Console
.WriteLine ($"{e}, {e.InnerException}");
57 Assert
.IsTrue (success
, "Bug46473 (exception during remoting call)");