LINQPadChart does not contain a defintion for 'ToWindowsChart'
Trying to migrate a big library of old scripts from Linqpad5 to Linqpad7 (gotta get at those new features!) and looking for advice on how to troubleshoot compilation errors seen when using lprun7.exe that don't seem to exist in LINQPad7 GUI or LINQPad5's lprun.
Specifically let's say we have a file test.linq that looks like this:
void Main()
{
new List() { 1, 2, 3 }
.Chart(c => c)
.ToWindowsChart();
}
We can run this in the LINQPad7 GUI without problem and no adjustment to namespace or imports.
But lprun7 yields:
_"CS1061 'LINQPadChart' does not contain a definition for 'ToWindowsChart' and no accessible extension method 'ToWindowsChart' accepting a first argument of type 'LINQPadChart' could be found (are you missing a using directive or an assembly reference?) line 4 column 5"
_
Have tried:
- On a few machines and OSs (Win10, Win11, Windows Server) and always the same
- Various strategies to manually include C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Windows.Forms.DataVisualization.dll (since AFAIK LINQPad5 used this) but LPRUN7 seems to always prefer the LINQPad version so doesn't make any difference
- Create same file in LINQPad5 and run with lprun - this works.
According to ILSpy from within LINQPad7, ToWindowsChart() doesn't exist in .NET 6.0.9 but does exist in .NET Framework used in LINQPad5, now unsupported in LINQPad7. That being the case, the error is fair enough and my bad. But then why the inconsistent behaviours between GUI and command line?
Any ideas on how to (with minimal rewrites) get something like this working in lprun7?
Comments
Not sure of how to get this working long term, but I can explain the inconsistency.
The Method exists, but is in in
LINQPad.Runtime.UI.dll
which is embedded as a resource insideLinqPad.Runtime.dll
and extracted and loaded at runtime by the GUI, but not by LpRun. For example on my machine it is found in%localappdata%\LINQPad\7.4.9
If you include a reference to this file then LpRun will work, but obviously this depends on the version of Linqpad you are using and not really a good idea.
Try the latest beta - it should now reference the LINQPad.Runtime.UI assembly.
Tried with Beta and now working well, both in the simple case above and more complex charting examples.
Thanks!