簡體   English   中英

當使用包含公共引用的兩個類庫時,C#-interactive會給出不明確的引用

[英]C#-interactive gives ambiguous references when using two class libraries containing a common reference

我正在嘗試使用VS 2015社區內的C#交互式窗口。

我有兩個類庫:CSVlib和FrameLib。 前者提到了后者。 這是失敗的交互式代碼:

> #r "D:\Documents\Visual Studio 2015\Projects\DataExplorer\CSVlib\bin\Debug\CSVlib.dll"
> using CSVlib;
> string fileName = @"D:\csvFiles\Players.csv";
> DataFrame frame = CSV.read(fileName);
> frame.colNames
List<string>(5) { "name", "city", "sex", "age", "weight" }
> ColumnData foo = frame["city"];
(1,1): error CS0246: The type or namespace name 'ColumnData' could not be found (are you missing a using directive or an assembly reference?)

ColumnData是在FrameLib中定義的類,由DataFrame索引器返回。 似乎可以通過CSVlib中的引用獲得類Frame,但不能使用ColumnData。 我試圖明確地引用Framelib,但無法使其工作:

> #r "D:\Documents\Visual Studio 2015\Projects\DataExplorer\FrameLib\bin\Debug\FrameLib.dll"
> using FrameLib;
> DataFrame df = new DataFrame();
(1,1): error CS0104: 'DataFrame' is an ambiguous reference between 'CSVlib.DataFrame' and 'FrameLib.DataFrame'
(1,20): error CS0104: 'DataFrame' is an ambiguous reference between 'CSVlib.DataFrame' and 'FrameLib.DataFrame'

我可以制作一個具有資格的DataFrame:

> FrameLib.DataFrame df = new FrameLib.DataFrame();

但是我無法使CSV.read語句生效(CSV.read返回一個DataFrame):

FrameLib.DataFrame frame = CSV.read(fileName);
(1,28): error CS0029: Cannot implicitly convert type 'CSVlib.DataFrame' to 'FrameLib.DataFrame'

交互式窗口之外的這個C#代碼(即在另一個項目中)工作正常:

 using CSVlib;
    using FrameLib;
    ...
    string fileName = @"D:\csvFiles\Players.csv";
    DataFrame frame = CSV.read(fileName);
    ColumnData foo = frame["city"];

我如何使用我的兩個庫使語句在交互式窗口中工作?

這是我的錯。 我有一個調試/構建誤解。 實際上,當我認為我使用的是“x86”時,確實有兩種類型定義,從“Any CPU”的調試版本中遺留下來。 事實上,事情按照預期運作。 感謝John Skeet; 抱歉。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM