小编And*_*ers的帖子

找不到类型或命名空间名称

我有C#几个项目的解决方案Visual Studio 2010.一个是测试项目(我将其称为" PrjTest "),另一个是Windows Forms Application项目(我将其称为" PrjForm ").还有一个由PrjForm引用的第三个项目,它能够成功引用和使用.

PrjForm引用PrjTest,而PrjForm有一个带有using语句的类:

using PrjTest;
Run Code Online (Sandbox Code Playgroud)
  1. 参考已正确添加
  2. using 声明正确到位
  3. 拼写是正确的
  4. PrjTest构建成功
  5. PrjForm几乎可以构建,但是会using PrjTest;出现错误:

找不到类型或命名空间名称'PrjTest'(您是否缺少using指令或程序集引用?)

我尝试过以下方法来解决这个问题:

  1. 删除了Resharper(因为Resharper在识别引用的项目时没有遇到任何麻烦,我认为它可能值得一试)
  2. 删除并重新添加了引用和using语句
  3. 从头开始重新创建PrjForm
  4. PrjForm目前驻留在PrjTest文件夹中,我尝试将其移动到外部文件夹
  5. 使用新的副本在另一台计算机上加载解决方案 VS 2010

我做完了我的功课,花了很长时间在线寻找答案,但这些解决方案都没有帮助.

我还能尝试什么?

c# reference using-directives using-statement visual-studio-2010

454
推荐指数
9
解决办法
75万
查看次数

将参数传递给page.includeJs()和page.evaluate()中的匿名函数

一点背景......我对javascript和phantom.js有点新,所以我不知道这是一个javascript还是phantom.js bug(功能?).

以下成功完成(对于缺少的phantom.exit(),您只需要在完成后按ctrl + c):

var page = require('webpage').create();
var comment = "Hello World";

page.viewportSize = { width: 800, height: 600 };
page.open("http://www.google.com", function (status) { 
    if (status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit();
    } else {
        page.includeJs('http://code.jquery.com/jquery-latest.min.js', function() {
            console.log("1: ", comment);
        }, comment);

        var foo = page.evaluate(function() {            
            return arguments[0];
        }, comment);

        console.log("2: ", foo);            
    }
});
Run Code Online (Sandbox Code Playgroud)

这有效:

page.includeJs('http://code.jquery.com/jquery-latest.min.js', function() {
    console.log("1: ", comment);
}, comment);
Run Code Online (Sandbox Code Playgroud)

输出:1: Hello World

但不是:

page.includeJs('http://code.jquery.com/jquery-latest.min.js', function(c) { …
Run Code Online (Sandbox Code Playgroud)

javascript phantomjs

17
推荐指数
1
解决办法
8565
查看次数

标签控制就像stackoverflow一样

是否有人知道c#的Winforms控件类似于stackoverflow使用的Tags控件(见下文)? 标签控制示例

如果没有,你用来处理标签的一些好的替代品是什么?

c# visual-studio-2010 winforms

12
推荐指数
2
解决办法
3408
查看次数

Windows SDK for Server 2008中缺少Inspect.exe

Windows SDK for Server 2008不包含Inspect.exe.有谁知道我在哪里可以找到Inspect.exe或AccExplorer32.exe的副本?我正在运行64位版本的Windows Server 2008 R2.

winapi windows-server-2008

8
推荐指数
1
解决办法
1万
查看次数

Nuget IVsPackageInstaller挂起

使用此代码:

public void InstallPackage(Project project, string packageId, string version, string packageSource)
{
    var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
    var installer = componentModel.GetService<IVsPackageInstaller>();

    installer.InstallPackage(packageSource, project, packageId, version, false);
}
Run Code Online (Sandbox Code Playgroud)

EntityFramework 6.1.3例如,当我尝试安装时,它只是挂起就installer.InstallPackage()行了.我让它运行长达10分钟,没有任何响应,错误,消息或任何关于发生了什么的指示.

我尝试了以下包源:

  1. https://nuget.org/api/v2
  2. 空值
  3. 下载包并引用本地仓库(例如C:\ Nuget)

都具有相同的结果.同样的事情发生的每包我试过(Newtonsoft.Json,Unity,等),所以它不只是EntityFramework.

这是在VS 2015和.Net 4.5.1中运行的.我已经引用了这个NuGet.VisualStudio 2.8.6包,但我也尝试过2.8.5和2.8.3但没有成功.

手动安装程序包(通过Visual Studio中的NuGet程序包管理器UI)按预期工作.

我也尝试了这个NuGet.CommandLine 2.8.6包,具有以下实现:

public void InstallPackage(Project project, string packageId, string version, string packageSource)
{
    var repo = PackageRepositoryFactory.Default.CreateRepository("https://nuget.org/api/v2");

    // Get the package install path
    var solutionDirectory = Path.GetDirectoryName(project.DTE.Solution.FullName); …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio vsix nuget

7
推荐指数
0
解决办法
396
查看次数

DateTime.UtcNow应该有时区偏移吗?

这个(LINQPad代码段):

DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz").Dump();
DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:sszzz").Dump();
Run Code Online (Sandbox Code Playgroud)

返回:

2016-01-08T09:05:04-07:00 // Expected
2016-01-08T16:05:04-07:00 // Not what I expected
Run Code Online (Sandbox Code Playgroud)

鉴于第二个结果是通用时间,我预计它会返回2016-01-08T16:05:04-00:00(时区偏移为零).

我错过了什么或这是一个错误吗?

.net c# datetime utc linqpad

5
推荐指数
1
解决办法
1042
查看次数

Angular 删除所有查询参数

与以下内容相关但不重复:访问 Angular 2 应用程序的路由时如何在 URL 中保留查询字符串参数?

我有一个非常基本的 Angular 应用程序,当我添加查询参数时,它会在代码命中构造函数之前被删除(从浏览器的 URL 和其他任何地方)app.component。

注意:在初始加载(以及随后的重新加载)时,查询参数似乎被剥离

示例:导航至localhost:8081/calculator?a=1更改为localhost:8081/calculator

我在 Angular 4.3.1、4.4.6 和 5.0.4 中尝试过此操作,结果相同。

这是我的路线配置:

const appRoutes: Routes = [
    {
        path: 'calculator',
        component: CalculatorComponent
    }
];

export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
Run Code Online (Sandbox Code Playgroud)

这是主应用程序组件的构造函数:

public constructor(private router: Router, private route: ActivatedRoute) {
    console.log('entered app constructor');
    this.route.queryParamMap.subscribe(params => {
        console.log('app', params);
    });
}
Run Code Online (Sandbox Code Playgroud)

这是计算器组件的构造函数:

constructor(private router: Router, private route: ActivatedRoute) {
    console.log('entered calc constructor');
    this.route.queryParamMap.subscribe(params => {
        console.log('calc', params); …
Run Code Online (Sandbox Code Playgroud)

typescript angular

5
推荐指数
1
解决办法
6935
查看次数

NSubstitute模拟通用方法

我在接口中有以下方法签名:

public interface ISettingsUtil
{
    T GetConfig<T>(string setting, dynamic settings);
}
Run Code Online (Sandbox Code Playgroud)

我试图嘲笑:

var settingsUtil = Substitute.For<ISettingsUtil>();
var maxImageSize = settingsUtil.GetConfig<long>("maxImageSize", 
                                              Arg.Any<dynamic>()).Returns(100L);
Run Code Online (Sandbox Code Playgroud)

这会Microsoft.CSharp.RuntimeBinder.RuntimeBinderException在第二行引发异常:

'long'不包含'Returns'的定义

有关如何T GetConfig<T>(string setting, dynamic settings)正确模拟的任何想法?

c# generics nsubstitute

4
推荐指数
2
解决办法
4669
查看次数

WebDriver可以使用xpath找到元素,Html Agility Pack不能

我一直遇到Html Agility Pack的问题; 我的XPath查询只有在非常简单时才能工作:

//*[@id='some_id']
Run Code Online (Sandbox Code Playgroud)

要么

//input
Run Code Online (Sandbox Code Playgroud)

但是,只要它们变得更复杂,那么Html Agility Pack就无法处理它.这是一个演示问题的示例,我使用WebDriver导航到Google,并返回页面源,传递给Html Agility Pack,WebDriver和HtmlAgilityPack都尝试定位元素/节点(C#):

//The XPath query
const string xpath = "//form//tr[1]/td[1]//input[@name='q']";

//Navigate to Google and get page source
var driver = new FirefoxDriver(new FirefoxProfile()) { Url = "http://www.google.com" };
Thread.Sleep(2000);

//Can WebDriver find it?
var e = driver.FindElementByXPath(xpath);
Console.WriteLine(e!=null ? "Webdriver success" : "Webdriver failure");

//Can Html Agility Pack find it?
var source = driver.PageSource;
var htmlDoc = new HtmlDocument { OptionFixNestedTags = true };
htmlDoc.LoadHtml(source);
var nodes = htmlDoc.DocumentNode.SelectNodes(xpath);
Console.WriteLine(nodes!=null …
Run Code Online (Sandbox Code Playgroud)

c# xpath webdriver visual-studio-2010 html-agility-pack

3
推荐指数
1
解决办法
3300
查看次数

Html Agility Pack无法使用xpath查找列表选项

这与我之前的问题有关,但似乎我有另一个案例,其中Html Agility Pack无法按预期工作.

这是Html(删除了必需品,删除了敏感信息):

<html>
<select id="one-time-payment-form:vendor-select-supplier">
    <option value="1848">Frarma Express</option>
    <option value="2119">Maderas Garcia</option>
    <option value="1974">Miaris, S.A.</option>
    <option value="3063">Ricoh Panama</option>
    <option value="3840">UNO EXPRESS</option>
    <option value="68">Garrett Blaser Gretsch</option>
    <option value="102">Oriel Antonio Grau</option>
</select>
</html>
Run Code Online (Sandbox Code Playgroud)

这是代码:

const string xpath = "//*[contains(@id, 'one-time-payment-form:vendor-select-')]/option[contains(text(), 'UNO EXPRESS')]";
var driver = new FirefoxDriver(new FirefoxProfile()) { Url = "PATH_TO_FILE_CONTAINING_HTML_SHOWN_ABOVE" };
Thread.Sleep(2000);

//Can WebDriver find it?
var e = driver.FindElementByXPath(xpath);
Console.WriteLine(e!=null ? "WebDriver success" : "WebDriver failure");

//Can Html Agility Pack find it?
var source = driver.PageSource; …
Run Code Online (Sandbox Code Playgroud)

c# xpath webdriver html-agility-pack

3
推荐指数
1
解决办法
1340
查看次数

批处理文件串联命令行参数

例如,我创建了一个名为的批处理文件concatenate.bat:

@echo off
set foo=%1\bar
echo %foo%
Run Code Online (Sandbox Code Playgroud)

当我跑步 concatenate.bat "C:\somewhere\with spaces"

我想要foo输出: "C:\somewhere\with spaces\bar"

但是我得到了: "C:\somewhere\with spaces"\bar


我也尝试过: set "foo=%1\bar"

哪个输出: "C:\somewhere\with spaces"\bar


正确的方法是什么?

batch-file

1
推荐指数
1
解决办法
7375
查看次数