Bug 23135 - Null reference exception on property value access of MarshalByRefObject
Summary: Null reference exception on property value access of MarshalByRefObject
Alias: None
Product: Runtime
Classification: Mono
Component: Remoting ()
Version: 3.8.0
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-09-18 06:50 UTC by Mike
Modified: 2018-02-28 21:59 UTC (History)
4 users (show)

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

NUnit test reproducing the issue (1.58 KB, application/octet-stream)
2014-09-18 06:50 UTC, Mike
Repro (2.94 KB, application/zip)
2018-02-28 21:59 UTC, Ludovic Henry

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 23135 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Mike 2014-09-18 06:50:57 UTC
Created attachment 8100 [details]
NUnit test reproducing the issue

Object reference not set to an instance of an object exception occurs in the following code:

var subDomain = CreateDomain ();
subDomain.DoCallBack(() =>
		AppDomain.CurrentDomain.SetData("remoteObject", new SomeMarshalByRefObject());
var remoteObject = subDomain.GetData("remoteObject") as SomeMarshalByRefObject;
subDomain.SetData("remoteObject", null);
var propertyInfo = typeof(SomeMarshalByRefObject).GetProperty("SomeStringProperty");
if (propertyInfo != null) {
	var propertyValue = propertyInfo.GetValue (remoteObject, null);
	if (propertyValue != null) {
                // The null reference exception occurs here on mono!
		Console.WriteLine ("The value of the remote object property is: {0}", propertyValue.ToString ());

The test runs without any problems on .net 4.5 

The following issue is 100% reproducible on latest mono master (3.10.x) running on ubuntu server 14.04 and also on
=== Xamarin Studio ===
Version 5.4 (build 239)
Installation UUID: 4693647f-46e0-4046-b430-f4f086d7fd6f
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)
	Package version: 308000009
=== Build Information ===
Release ID: 504000239
Git revision: 338110385bb89c5774e89ffcb15d8f2039e7fbcd
Build date: 2014-09-16 12:25:53-04
Xamarin addins: 05241f5ab70cf79388a0f113bc6877780ed1024a
=== Operating System ===
Mac OS X 10.10.0
Darwin 14.0.0 Darwin Kernel Version 14.0.0
Comment 1 Mike 2014-09-18 06:59:04 UTC
As I've already said, the test runs successfully without any errors on
Microsoft .NET Framework Version 4.5.51641
running on Microsoft Windows 8.1 Pro Version 6.3.9600 Build 9600
Comment 2 Ludovic Henry 2018-02-28 21:58:38 UTC
I can reproduce with Mono (master/798c5efa52a), and I verified the same code doesn't have the exception on .NET Framework on Windows.
Comment 3 Ludovic Henry 2018-02-28 21:59:18 UTC
Created attachment 26192 [details]