In my LINQPad script I need to use System.Windows.Forms.DataVisualization.Charting.Chart to create some graphs - the following code works fine for this purpose.
void Main()
{
List<int> a = new List<int>() { 1, 2, 3, 4, 5 };
var winChart = a.Chart().ToWindowsChart();
winChart.ToBitmap().Dump();
winChart.Name = "MyName";
winChart.PrintName();
}
public static class Ext
{
public static void PrintName(this System.Windows.Forms.DataVisualization.Charting.Chart chart)
{
Console.WriteLine(chart.Name);
}
}
LINQPad seems to resolve the System.Windows.Forms.DataVisualization.Charting namespace from a .DLL named LINQPad.Windows.Forms.DataVisualization.dll - OK fine. But I also need to add another DLL as a reference for another purpose, and the other .DLL depends on the System.Windows.Forms.DataVisualization nuget package.
Now I have System.Windows.Forms.DataVisualization namespace being provided from two DLLs, and LINQPad displays the following error:
CS0433 The type 'Chart' exists in both 'LINQPad.Windows.Forms.DataVisualization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'System.Windows.Forms.DataVisualization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
The usual way to solve this in Visual Studio would be to use extern alias, but I don't think that is available in LINQPad.
Before adding in my dependent DLL, I checked Query Properties -> Advanced -> Show Assembly Resolution log and it shows LINQPad.Windows.Forms.DataVisualization.dll as a Managed Reference.
This managed reference disappears after I add my dependent DLL which introduced the namespace conflict, but it still produced the error.