[Mono-bugs] [Bug 60303][Maj] New - AppDomain.CreateInstanceAndUnwrapFrom() flags implicate different behaviour in .NET and Mono

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 16 Jun 2004 14:38:00 -0400 (EDT)


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 infodate@aster.pl.

http://bugzilla.ximian.com/show_bug.cgi?id=60303

--- shadow/60303	2004-06-16 14:38:00.000000000 -0400
+++ shadow/60303.tmp.12924	2004-06-16 14:38:00.000000000 -0400
@@ -0,0 +1,111 @@
+Bug#: 60303
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: WinXP SP1 PL fully patched mono-beta2 .NET 1.1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: infodate@aster.pl               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: AppDomain.CreateInstanceAndUnwrapFrom() flags implicate different behaviour in .NET and Mono
+
+Description of Problem:
+While calling method CreateInstanceAndUnwrapFrom(.., .., .. ..) on 
+AppDomain object the following behaviour is observed: results of call 
+depend on type of CLR environment used and on settings of BindigFlags.
+
+On .NET v1.1 when BindingFlags.CreateInstance are set only accessible 
+constructors are called. When BindingFlags.Public or BindigFlags.Non-
+public are set method throws exception:
+
+Constructor on type CilDebugging.RemoteLoader not found.
+
+Server stack trace:
+   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, 
+Binder binder, Object[] args, CultureInfo culture, Object[] activation
+Attributes)
+   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, 
+Binder binder, Object[] args, CultureInfo culture, Object[] activ
+ationAttributes)
+   at System.Activator.CreateInstanceFrom(String assemblyFile, String 
+typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder,
+ Object[] args, CultureInfo culture, Object[] activationAttributes, 
+Evidence securityInfo)
+   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String 
+typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder,
+ Object[] args, CultureInfo culture, Object[] activationAttributes, 
+Evidence securityAttributes)
+   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, 
+String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binde
+r binder, Object[] args, CultureInfo culture, Object[] 
+activationAttributes, Evidence securityAttributes)
+   at 
+System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage
+(MethodBase mb, Object[] args, Object server, Int32 methodPtr,
+ Boolean fExecuteInContext, Object[]& outArgs)
+   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage
+(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
+
+Exception rethrown at [0]:
+   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage
+(IMessage reqMsg, IMessage retMsg)
+   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& 
+msgData, Int32 type)
+   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, 
+String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binde
+r binder, Object[] args, CultureInfo culture, Object[] 
+activationAttributes, Evidence securityAttributes)
+
+On Mono-beta2 while only BindingFlags.CreateInstance flag is set 
+application throws the following exception:
+
+Constructor not found.
+in <0x006eb> System.Runtime.Remoting.Proxies.RealProxy:PrivateInvoke 
+(System.Runtime.Remoting.Proxies.RealProxy,System.Runtime.Remoting.Mess
+aging.IMessage,System.Exception&,object[]&)
+
+Setting flags to CreateInstance|Non-public|Public allows for access to all 
+constructors in Mono while .NET will fails with method execution (see 
+exception above).
+
+
+Steps to reproduce the problem:
+
+1. Create simple app containing following code:
+
+// Create new Application Domain
+appDom = AppDomain.CreateDomain("XXXXXX" + index.ToString(), null, 
+appSetup);
+
+// Prepare arguments which will be passed to the constructor of
+// RemoteLoader
+object[] args = new object[2];
+args[0] = this.ResolvedAssemblies;
+args[1] = this.BuildData.MainDirectory;
+
+// Create RemoteLoader and retrieve proxy - rl.
+RemoteLoader rl = (RemoteLoader) 
+appDom.CreateInstanceFromAndUnwrap( 			
+	"XXXXXX.dll", "XXXXXX.RemoteLoader", 
+	false, BindingFlags.CreateInstance|BindingFlags.Public,
+	null, args, null, null, null);
+2. Create remote class with different constructors.
+3. Change settings of BindingFlags and test creation of class in new 
+appdoamin.
+
+Actual Results:
+Behaviour of .NET and Mono differs making this same code useless on other 
+implementation of CLR thus preventing easy porting.
+
+
+Expected Results:
+The same behaviour on both platforms. Both MS and Mono platforms solutions 
+are OK from logical point of view but obviously only one standardized 
+approach should prevail.