[Mono-bugs] [Bug 75357][Nor] New - Impossible to unload domain if
it contained remoting object
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jun 22 20:05:46 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by pisanko at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75357
--- shadow/75357 2005-06-22 20:05:46.000000000 -0400
+++ shadow/75357.tmp.25796 2005-06-22 20:05:46.000000000 -0400
@@ -0,0 +1,153 @@
+Bug#: 75357
+Product: Mono: Runtime
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Ubuntu Linux 5.04
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: remoting
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: pisanko at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Impossible to unload domain if it contained remoting object
+
+1. Create new application domain
+2. Create object in newly created application domain.
+3. Register that object as remoting server.
+4. Call some method of that object via remoting.
+5. Degister all remoting stuff for object.
+6. Unload application domain gives following exception:
+
+Unhandled Exception: System.CannotUnloadAppDomainException: Attempt to
+unload application domain failed.
+in <0x00000> <unknown method>
+in (wrapper managed-to-native) System.AppDomain:InternalUnload (int)
+in <0x0001d> System.AppDomain:Unload (System.AppDomain domain)
+in <0x00029> Bug.Server:Stop ()
+in <0x00119> Bug.AppDomainAndRemotingBug:Main (System.String[] args)
+
+If you'll skip step number 4, domain will unloaded without any problem.
+That scenario works perfectly on MS .NET 1.1. Seems like this issue is
+related to Bug #72684.
+
+Following piece of code shows described scenario:
+
+--- console application ---
+
+using System;
+using System.Threading;
+using System.Reflection;
+using System.Collections;
+using System.Net;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Serialization.Formatters;
+
+namespace Bug
+{
+ public class AppDomainAndRemotingBug
+ {
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ Server.Start();
+
+ TcpChannel tcpChannel = new TcpChannel();
+ ChannelServices.RegisterChannel(tcpChannel);
+
+ Server server = (Server)RemotingServices.Connect(typeof(Server),
+ new UriBuilder("tcp", "localhost", 9567, typeof(Server).Name).ToString());
+
+ Console.WriteLine(server.Name);
+ server = null;
+
+ ChannelServices.UnregisterChannel(tcpChannel);
+ tcpChannel = null;
+
+ Server.Stop();
+ }
+ }
+}
+
+--- Library ---
+
+using System;
+using System.Threading;
+using System.Reflection;
+using System.Collections;
+using System.Net;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+using System.Runtime.Serialization.Formatters;
+
+namespace Bug
+{
+ public class Server : MarshalByRefObject
+ {
+ protected static AppDomain applicationDomain = null;
+ protected TcpChannel tcpChannel = null;
+ protected static Server domainServerInstance = null;
+ protected static Server remotedServerInstance = null;
+
+ protected void RegisterForRemoting()
+ {
+ tcpChannel = new TcpChannel(9567);
+ remotedServerInstance = new Server();
+ ChannelServices.RegisterChannel(tcpChannel);
+ RemotingServices.Marshal(remotedServerInstance, typeof(Server).Name,
+typeof(Server));
+ }
+
+ public void DeregisterForRemoting()
+ {
+ RemotingServices.Disconnect(remotedServerInstance);
+ remotedServerInstance = null;
+ ChannelServices.UnregisterChannel(tcpChannel);
+ }
+
+ public static void Start()
+ {
+ AppDomainSetup applicationDomainSetup = new AppDomainSetup();
+ applicationDomainSetup.ApplicationBase =
+AppDomain.CurrentDomain.BaseDirectory;
+ applicationDomain = AppDomain.CreateDomain("Server Domain", null,
+applicationDomainSetup);
+ BindingFlags flags = (BindingFlags.Public | BindingFlags.Instance |
+BindingFlags.CreateInstance);
+ domainServerInstance = (Server)applicationDomain.CreateInstanceAndUnwrap(
+ Assembly.GetExecutingAssembly().FullName,
+ typeof(Server).FullName,
+ false,
+ flags,
+ null,
+ null,
+ null,
+ null,
+ null);
+ domainServerInstance.RegisterForRemoting();
+ }
+
+ public static void Stop()
+ {
+ domainServerInstance.DeregisterForRemoting();
+ domainServerInstance = null;
+ AppDomain.Unload(applicationDomain);
+ applicationDomain = null;
+ }
+
+ public string Name
+ {
+ get
+ {
+ return "Server Name";
+ }
+ }
+ }
+}
More information about the mono-bugs
mailing list