Ticket Hash: | 872a6909965c7fa6913aa33414a466562aacbeb0 | |||
Title: | Null reference in SQlChecker on .Net 3.5 | |||
Status: | Closed | Type: | Code_Defect | |
Severity: | Important | Priority: | Immediate | |
Subsystem: | None | Resolution: | Fixed | |
Last Modified: | 2011-07-19 17:39:49 | |||
Version Found In: | 1.0.74.0 | |||
Description: | ||||
Any code which uses SqlChecker on .Net 3.5 will fail with a null reference exception. The static constructor looks up "System.Data.SqlClient.SqlGen.Sql8ExpressionRewriter" in "System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". It doesn't check whether this is successful and if it isn't when calling "Rewrite" a NullReferenceException will be thrown as "sql8rewriter" is null. I would suggest 2 fixes:
1. change the static constructor to:
static SqlChecker() { sql8rewriter = Type.GetType("System.Data.SqlClient.SqlGen.Sql8ExpressionRewriter, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false); if (sql8rewriter == null) { sql8rewriter = Type.GetType("System.Data.SqlClient.SqlGen.Sql8ExpressionRewriter, System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false); } } 2. in Rewrite() check if sql8rewriter is null and if it is throw an exception mistachkin added on 2011-07-18 23:17:32 UTC: anonymous added on 2011-07-19 10:12:59 UTC: mistachkin added on 2011-07-19 17:39:49 UTC: |