System.Data.SQLite

View Ticket
Login
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
13.95 years ago
Created: 2011-07-18 12:53:54
13.95 years ago
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

<hr /><i>mistachkin added on 2011-07-18 23:17:32 UTC:</i><br />
Fixed as of check-in [76e929f694].


<hr /><i>anonymous added on 2011-07-19 10:12:59 UTC:</i><br />
there still is no check if sql8rewriter is null. The fix means that it shouldn't be null but just in case an explicit check would make it easier to track down the problem in the future

<hr /><i>mistachkin added on 2011-07-19 17:39:49 UTC:</i><br />
The code requiring the 'SQL 8 Re-writer' was completely disabled by the check-in I mentioned, because it is no longer required.