On Sat, 2008-03-15 at 12:53 -0400, Miguel de Icaza wrote:
> Hello Brad,
>
> In your patch, wouldn't it be easier to catch the return value from:
>
> Provider provider = providers [ProviderName];
>
> And if null, report that the provider was not found, instead of
> adding an extra loop?
Yes - that's superior. I'm not sure why I didn't do that in the first
place. I've tested the by-name index with bogus input and it does return
null in all relevant cases.
here's an updated patch.
brad
Index: ChangeLog
===================================================================
--- ChangeLog (revision 98283)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2006-03-08
+ * check immediatly to see if a provider fails to load
+ otherwise it's possible to attempt to dereference a null value
+
2006-02-13 Daniel Morgan <[EMAIL PROTECTED]>
* ProviderSectionHandler.cs
Index: Provider.cs
===================================================================
--- Provider.cs (revision 98283)
+++ Provider.cs (working copy)
@@ -132,7 +132,13 @@
providerAssembly = Assembly.LoadWithPartialName (assemblyName);
else
providerAssembly = Assembly.Load (assemblyName);
+
+ //if it's still null then the provider was not loadable
+ if (providerAssembly == null)
+ throw new Exception (String.Format ("Unable to load type of connection class: {0} from an assembly named: {1}. Is it installed?",
+ connectionTypeName, assemblyName));
}
+
return providerAssembly;
}
Index: ProviderFactory.cs
===================================================================
--- h:/docs/unh/AOSExpDB/DBLib/Mono.Data.upstream/ProviderFactory.cs (revision 98283)
+++ h:/docs/unh/AOSExpDB/DBLib/Mono.Data.upstream/ProviderFactory.cs (working copy)
@@ -99,6 +99,10 @@
throw new System.ArgumentNullException ("ConnectionString");
Provider provider = providers [ProviderName];
+
+ if (provider == null)
+ throw new System.ArgumentOutOfRangeException("ProviderName", ProviderName, "Unable to find a provider of the specified class in the list of available providers from app.config or machine.config.");
+
IDbConnection conn = provider.CreateConnection ();
conn.ConnectionString = ConnectionString;
return conn;
_______________________________________________
Mono-devel-list mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-devel-list