Using LINQPad-generated TypedDataContext in a Visual Studio project

edited July 2022

How to use a TypedDataContext generated by LINQPad in a Visual Studio project?

I have a .linq script which I convert into a .cs file, using some simple text processing, to load as part of a Visual Studio project. It depends on a generated TypedDataContext with two database connections. This was done on LINQPad 6, .Net 3.1, VS 2019.

My purpose is to keep running it as a LINQPad script, but to be able to share it as a Visual Studio project that compiles into a .DLL.

The problem is that I cannot update the TypedDataContext. I wonder if there's now a "proper" way of doing it, with LINQPad 7 (eg. using nuget LINQPad.Reference), rather than a collection of hacks.

This worked a few months ago:

  • Reference LINQPad.Drivers.LibqToSql.dll
  • Reference SD.Tools.LinqToSQL2
  • Reference TypedDataContext_xyz....DLL
  • Nuget LINQPad.Runtime 6.7.5
  • Nuget System.Data.SqlClient 4.8.2

Now (when I update TypedDataContext_xyz...) this fails at runtime with:

"Could not load assembly 'LINQPad.Drivers.common, version="

which is actually assembly used by the script but which does not have a corresponding file (".Location").

I have tried to redo in various combinations of LINQPad 6 and 7, versions of the libraries, nuget LINQPad.Reference, etc.


  • I can't help you in terms of a proper way, but you should be able to work around that particular error. If you call or access any method or property in the Util class, it will activate the static constructor which will configure an assembly resolver for LINQPad's internal dependencies.

Sign In or Register to comment.