Home

Cannot add Assembly Reference in LinqPad v6 x64

It used to be so intuitive in v5, press F4 and then add namespaces and add .NET assembly references. In v6 it is broken, I press F4 and can add a namespace but I need to add an assembly reference and that seems not to be possible. I pressed the Browse button but it does NOT list the .NET assemblies, instead it takes me to my queries folder.

Comments

  • Apparently the updated System.Management that doesn't produce the error is only available in NUGET and for that a Premium version is needed.

  • With .NET Core all of the Framework's assemblies are referenced automatically, which is why you don't see that option in LINQPad 6. Visual Studio works in the same way.

    Regarding the NuGet reference, if you don't have a paid license, there are a couple of options. The first is to edit the .linq file to add the NuGet reference. After saving the query, pressing Ctrl+K, O will open the query in Windows Explorer. Then edit the .linq file in notepad - you can add a reference as follows:

    <Query Kind="Statements">
      <NuGetReference>System.Management</NuGetReference>
    </Query>
    

    The other is to download the package using the NuGet command-line, then reference the assembly either from where you downloaded it, or the NuGet cache:

    %userprofile%\.nuget\packages\System.Management\4.7.0\runtimes\win\lib\netcoreapp2.0\System.Management.dll

  • I hate to necro a thread, but I don't understand the bit about "With .NET Core"-specifically. I'm in seemingly the same boat as the OP. I don't know whether they were working against .NET Framework (5.0.7) or .NET Core, but I'm working with WinForms, and from what I can see, I am able to run my WinForms code in the editor just fine, but lprun complains about missing references. Then I go to F4 and see the [ Add / Browse ], and I'm now lost when the window comes up without any references. Is there some other switch or something that I need to throw at the lprun, perhaps?

  • LPRun is not really designed to run WinForms or WPF code - it's command-line only. What are you trying to accomplish?

  • I build a lot of utility/monitoring/reporting tools for our operations people at my company, and a test harness for some of that was what I was just setting up. We make extensive use of LINQPad with WinForms code though, and we just recently upgraded our site license (and my personal, for what it's worth; been with you for many many moons) to LP6. We haven't made the switch to it at work yet; that's why I'm prototyping currently. I have a convention-based process scheduling engine (built in LINQPad as well) that runs from a Windows Task Schedule. It periodically launches files, monitors their process, stops/updates/restarts them as needed. It isn't constrained to running scripts though, so .exe's, .bat's, or even URLs could be launched. I only mention that last bit to clarify why the LP-based launcher isn't using Util.Run(). To simulate a user input step of a process, I thought for sure throwing a Form up with a wait thread and a Form.Close event to unblock it would work just fine. Turns out, not so much, so then I dialed it back, thinking I'd messed up my ~four lines of code somehow. Commented it all, threw a MessageBox.Show("something"); out there, nothing. So ran it in cmd to be able to actually read the output, and that's when I saw that it had no idea what a MessageBox was, despite it working in LINQPad no problem. I'll be honest, we've never ran into anything like this with LP5, and we run many highly functional production automation scripts via lprun currently. They have Framework code in them (as they were never meant to be Core), and I was under the impression that with LP6 having the ".NET" and ".NET Core" as separate options meant one editor for both Core and Fx. I'm starting to feel like that was an inaccurate assumption.

Sign In or Register to comment.