【发布时间】:2019-08-22 02:33:22
【问题描述】:
所以在 IDE 中我有以下内容:
public static void ConnectToOperaObjects(ref Microsoft.ClearScript.Windows.JScriptEngine jSE)
{
foreach (Tuple<string, object> tso in new List<Tuple<string, object>>() {
(name: "CSOperaDriver", type: typeof(OpenQA.Selenium.Opera.OperaDriver)),
(name: "CSOperaDriverService", type: typeof(OpenQA.Selenium.Opera.OperaDriverService)),
(name: "CSOperaOptions", type: typeof(OpenQA.Selenium.Opera.OperaOptions)) })
{
jSE.AddHostType(tso.name, tso.type);
}
}
IDE 毫无疑问地编译它。命令行编译器抱怨
Objects.cs(161,17): error CS1950: The best overloaded Add method 'List<Tuple<string, object>>.Add(Tuple<string, object>)' for the collection initializer has some invalid arguments [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(161,17): error CS1503: Argument 1: cannot convert from '(string, System.Type)' to 'Tuple<string, object>' [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(162,17): error CS1950: The best overloaded Add method 'List<Tuple<string, object>>.Add(Tuple<string, object>)' for the collection initializer has some invalid arguments [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(162,17): error CS1503: Argument 1: cannot convert from '(string, System.Type)' to 'Tuple<string, object>' [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(163,17): error CS1950: The best overloaded Add method 'List<Tuple<string, object>>.Add(Tuple<string, object>)' for the collection initializer has some invalid arguments [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(163,17): error CS1503: Argument 1: cannot convert from '(string, System.Type)' to 'Tuple<string, object>' [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(165,42): error CS1061: 'Tuple<string, object>' does not contain a definition for 'name' and no accessible extension method 'name' accepting a first argument of type 'Tuple<string, object>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
Objects.cs(165,52): error CS1061: 'Tuple<string, object>' does not contain a definition for 'type' and no accessible extension method 'type' accepting a first argument of type 'Tuple<string, object>' could be found (are you missing a using directive or an assembly reference?) [C:\Users\bugma\Source\Repos\RR\RR\RR.csproj]
命令行工具被调用为
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64\MSBuild.exe" %* /t:Build
使用 RR 的 csproj 文件作为参数。我已经尝试为它提供sln 文件,但没有效果。
解决方法是什么?
【问题讨论】:
-
建议不要编辑帖子,而是创建一个自我回答,似乎更有用
标签: c# visual-studio msbuild