lprun has exception NullReferenceException, Query in windows run as expected


I run an LINQPad SQL query (lin2db provider) without any issues. If I try to run the same query with LPRUN.exe (Batch-File) I get a NullReferenceException. Mere snippets (without LINQ SQL) work fine for both LINQPad and LPRUN.exe.

Other LINQ SQL queries with linq2db provider have the same behavior. I tried with: sql2db provider for SQL Server and ACCESS.

I tried LINQ SQL with one of the samples with Microsoft SQL provider and it works fine.

Any idea?

Thanks a lot and best regards,


NullReferenceException: Object reference not set to an instance of an object.
at LinqToDB.LINQPad.DriverHelper.<>c__DisplayClass2_0.b__0(TraceInfo info) in C:\projects\linq2db-linqpad\Source\DriverHelper.cs:line 211
at LinqToDB.Data.DataConnection.ExecuteReader(CommandBehavior commandBehavior) in c:\projects\linq2db\Source\Data\DataConnection.cs:line 838
at LinqToDB.Data.DataConnection.LinqToDB.IDataContext.ExecuteReader(Object query) in c:\projects\linq2db\Source\Data\DataConnection.Linq.cs:line 264
at LinqToDB.Linq.Query`1.d__12.MoveNext() in c:\projects\linq2db\Source\Linq\Query.cs:line 411
at LinqToDB.Linq.Query`1.
d__69.MoveNext() in c:\projects\linq2db\Source\Linq\Query.cs:line 1213
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at UserQuery.query(String component) in d:\hoData\Development\LINQPad\LINQPad Queries\ZF_Module_Check.linq:line 48
at UserQuery.Main(String[] args) in d:\hoData\Development\LINQPad\LINQPad Queries\ZF_Module_Check.linq:line 14
at LINQPad.ExecutionModel.ClrQueryRunner.Run()
at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)


  • I've looked at the source code for linq2db and found the likely cause: it's writing to the SQL translation tab using a TextWriter which is null when called from lprun.

    I've modified LINQPad to assign a null writer in this scenario, so hopefully this will fix the problem. You can download the new beta here:

    Let me know how you get along.
  • Hi Joe,

    Thanks a lot. It works fine.

    Best regards,

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!