【发布时间】:2021-03-15 06:59:35
【问题描述】:
我正在使用 Visual Studio 2019 并且有一个控制台应用程序,它使用目标框架 .NET core 3.1 运行一些 selenium 测试。我最近添加了代码以使用 Windows 表单在我的应用程序中上传文件。
System.Windows.Forms.SendKeys.SendWait(absolutePath);
System.Windows.Forms.SendKeys.SendWait("{Enter}");
当我构建它时,我得到了以下错误:
The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
所以我搜索并更新了我的项目文件以在 PropertyGroup 中添加以下两个标签:
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
欢呼,它不再在本地抱怨了。但是,当我在 Teamcity 中构建应用程序时,我得到了同样的错误。有谁知道为什么会发生这种情况。我用谷歌搜索了更多,每个人都在谈论添加程序集引用。但我没有在 Visual Studio 中添加引用的选项。
MissingAssemblyReferences:
我尝试将其添加为 COM 依赖项,但也没有用。
但是,我确实看到在 Dependencies > Frameworks> System.Windows.Forms 下可用。
框架:
谁能帮我理解为什么它还在抱怨。
同样,它在 Visual Studio 本地和命令行上都可以正常工作,这只是 Teamcity 中的问题。 Teamcity 中运行的命令如下:
"C:\Program Files\dotnet\dotnet.exe" build <myTestApp>.sln @C:\BuildAgent\temp\agentTmp\a84ed99789454a3fa1f0d0028fcff404.rsp
提前致谢!
【问题讨论】:
标签: .net visual-studio-2019 assembly-references