Home

LINQPad 6 error with referenced library.

I have a DLL I am referencing in a query and I am getting this error:
FileNotFoundException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

This query works without issue in LINQPad 5, but does not work in the latest version. I'm kind of stuck as I'd prefer not to keep both versions installed unless necessary. The referenced DLL just returns a list from a legacy database table via a LINQ query. I do this so as I don't have a linked server and this data resides on a different DB server. That being said, I am sure there are some differences, but I am not sure what it is and how to resolve.

I tried to add a reference to the System.Data.Linq DLL and get this error:
BadImageFormatException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)

Comments

  • I take it you're running LINQPad 6? Because LINQPad 6 targets .NET Core, the assemblies that you reference are also supposed to target .NET Core (or .NET Standard). If you're trying to reference an assembly that targets .NET Framework, you may run into this error. Microsoft provide only partial support for .NET Core referencing .NET Framework.

  • edited September 2020

    So that means I and all others, like @suprduprmn, who targets .Net framework in their assemblies must run LINQPad 5 in parallel with LINQPad 6 in order to execute our queries?
    There is no setting for which .Net version to target for each query?
    EDIT: I see now on the download page that LINQPad 5 and LINQPad 6 both list which .Net version they are compatible with, so essentially one needs one LINQPad version per .Net incarnation.

  • Not exactly: The latest LINQPad 6 beta lets you choose which version of .NET Core to target per query (.NET 5, .NET Core 3.1 and .NET Core 3.0). Going forward, I plan to extend the list with .NET 6 so that LINQPad 7 will support .NET 6, .NET 5, and .NET 3.x.

    Of course, it would it would be ideal if .NET Framework was added to the list, but doing so is problematic because of all the ways in which it's incompatible with the other .NETs. So far, I've not found a way to solve all the problems.

  • Definitevely important.
    Talking of Linqpad 7, Im considering purchasing Linqpad, but wondering if I should stay as I am till 7 comes out.

    Cheers

  • I am using Linqpad 7 and facing the same problem. No matter which .Net version I select, I get this message.
    Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

Sign In or Register to comment.