Browse Source

2006-09-08 Gonzalo Paniagua Javier <[email protected]>

	* ObjectDataSourceView.cs: correctly find the type when it is not in the
	executing assembly. Fixes bug #78321. Patch by Marek Habersack.


svn path=/trunk/mcs/; revision=65131
Gonzalo Paniagua Javier 19 years ago
parent
commit
853fc2c487

+ 5 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,8 @@
+2006-09-08 Gonzalo Paniagua Javier <[email protected]>
+
+	* ObjectDataSourceView.cs: correctly find the type when it is not in the
+	executing assembly. Fixes bug #78321. Patch by Marek Habersack.
+
 2006-09-08 Gonzalo Paniagua Javier <[email protected]>
 
 	* ControlParameter.cs: fix search for controls so that they use their

+ 51 - 4
mcs/class/System.Web/System.Web.UI.WebControls/ObjectDataSourceView.cs

@@ -483,11 +483,55 @@ namespace System.Web.UI.WebControls
 				return updateParameters;
 			}
 		}
-		
+
+		private static string privateBinPath;
+    
+		private static string PrivateBinPath
+		{
+			get {
+    				if (privateBinPath != null)
+        				return privateBinPath;
+
+    				AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+    				privateBinPath = Path.Combine(setup.ApplicationBase, setup.PrivateBinPath);
+
+    				return privateBinPath;
+    			    }
+		}
+    
+	        private Type LoadType(string typeName)
+		{
+    			Type type = null;
+    			Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
+
+    			foreach (Assembly ass in assemblies) {
+    				type = ass.GetType (typeName);
+    				if (type == null)
+        				continue;
+
+    				return type;
+    			}
+
+    			if (!Directory.Exists (PrivateBinPath))
+    				return null;
+
+    			string[] binDlls = Directory.GetFiles(PrivateBinPath, "*.dll");
+    			foreach (string s in binDlls) {
+    				Assembly binA = Assembly.LoadFrom (s);
+    				type = binA.GetType (typeName);
+    				if (type == null)
+        				continue;
+
+    				return type;
+    			}
+
+    			return null;
+		}
+    
 		Type ObjectType {
 			get {
 				if (objectType == null) {
-					objectType = Type.GetType (TypeName);
+					objectType = LoadType (TypeName);
 					if (objectType == null)
 						throw new InvalidOperationException ("Type not found: " + TypeName);
 				}
@@ -498,7 +542,7 @@ namespace System.Web.UI.WebControls
 		Type DataObjectType {
 			get {
 				if (dataObjectType == null) {
-					dataObjectType = Type.GetType (DataObjectTypeName);
+					dataObjectType = LoadType (DataObjectTypeName);
 					if (objectType == null)
 						throw new InvalidOperationException ("Type not found: " + DataObjectTypeName);
 				}
@@ -787,7 +831,10 @@ namespace System.Web.UI.WebControls
 		
 		MethodInfo GetObjectMethod (string methodName, IOrderedDictionary parameters)
 		{
-			MemberInfo[] methods = ObjectType.GetMember (methodName);
+			MemberInfo[] methods = ObjectType.GetMember (methodName, BindingFlags.Instance | 
+										 BindingFlags.Static | 
+										 BindingFlags.Public | 
+										 BindingFlags.FlattenHierarchy);
 			if (methods.Length > 1) {
 				// MSDN: The ObjectDataSource resolves method overloads by method name and number
 				// of parameters; the names and types of the parameters are not considered.