小编lyn*_*ker的帖子

无法转换'System.Collections.Generic.List`1类型的对象

我不明白这个引用另一种类型'System.Collections.Generic.List`1 [CES.Model.SearchResult]'以及如何解决这个问题.

Unable to cast object of type 'System.Collections.Generic.List`1[CES.Model.SearchResult]' to type 'CES.Model.SearchResult'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[CES.Model.SearchResult]' to type 'CES.Model.SearchResult'.

Source Error: 


Line 1069:            XmlSerializer xs = new XmlSerializer(typeof(SearchResult));
Line 1070:            TextWriter textWriter = new StreamWriter(@"C:\temp\results.xml");
Line 1071:            xs.Serialize(textWriter, results);
Line 1072:            ViewState["eventList"] = …
Run Code Online (Sandbox Code Playgroud)

.net c# xml serialization list

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

找不到类型或命名空间MongoServer

参考这个Azure教程,https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-store-data-mongodb-vm/,三个月前发布,并且显然已经过时了.

我按照说明复制了代码,但无法使用此错误构建应用程序:CS0246类型或命名空间MongoServer无法找到Dal.cs第13行.

Azure支持响应"如果类型或命名空间不可用,通常是因为缺少程序集或DLL." 同意,但没有丢失的程序集或DLL.我怀疑API已经改变但是找不到支持这种怀疑的文档.因此,我无法解决问题.

在此输入图像描述

我已经包含了一个截图,显示了相关的程序集已安装.

我原本怀​​疑MongoDb.driver API已经改变了.该示例使用版本2.0.1,我安装了最新的2.2.4.但是,卸载最新版本并安装版本2.0.1后,我得到三个错误,原始加上另外两个错误.我想知道,这段代码最初是如何构建的?

c# azure mongodb

5
推荐指数
2
解决办法
7613
查看次数

AngularJS OrderBy:如何从自定义排序函数调用默认比较器

我有一个自定义排序功能,可将字符串转换为网格中一列的数字。其他列由字符串或日期值组成。我有一个自定义的排序功能,该功能检查数字列并执行转换,但是对于其他值,我需要默认比较器的行为。我该如何实现?

$scope.sort = function (keyname) {
  $scope.sortKey = keyname;
  $scope.reverse = !$scope.reverse;
};


$scope.sortSubGrid = function (a, b) {
  if ($scope.sortKey === 'caseNumber') {
    return = parseInt(b.value) -parseInt(a.value);
  }
  else {
    return = a.value > b.value;
  }
};
Run Code Online (Sandbox Code Playgroud)
<tr dir-paginate="agreement in agreements|orderBy:sortKey:reverse:sortSubGrid" ...>
Run Code Online (Sandbox Code Playgroud)

sortSubGrid函数的后半部分旨在对非数字列进行排序,但未达到我期望的结果,这只是默认比较器提供的结果。如何获得第二个子句的默认行为?

sql-order-by comparator angularjs

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

使用 Selenium Webdriver 处理 Windows 身份验证

在 C# 中基于 Selenium Webdriver 的测试必须使用 Windows 身份验证登录。

我尝试了几种方法:

  _Driver.SwitchTo().Alert();
  _Driver.FindElement(By.Id("UserName")).SendKeys("LynnTest");
  _Driver.FindElement(By.Id("Password")).SendKeys("Welcome1!");
  _Driver.SwitchTo().Alert().Accept();
  _Driver.SwitchTo().DefaultContent();
Run Code Online (Sandbox Code Playgroud)

  IAlert alert = _Driver.SwitchTo().Alert();
  alert.SendKeys("LynnTest\\t");
  alert.SendKeys("Welcome1!");
  _Driver.SwitchTo().Alert().Accept();
  _Driver.SwitchTo().DefaultContent();
Run Code Online (Sandbox Code Playgroud)

没有一个是成功的。我的本地系统上没有 Windows 身份验证对话框,因此我无法查看源代码以确定如何使用 Selenium By 方法定位用户名和密码。

我相信 Windows 身份验证对话框是由浏览器提供的,但我还没有找到该对话框的任何来源。

使用 Selenium(不是 AutoIt 或其他类似工具)如何将用户名和密码传递到 Windows 身份验证对话框中?解决方案必须基于 Selenium 代码,而不是加载项,我无法访问云中的浏览器。

注意:在 URL 中传递用户名和密码不起作用,据我了解,因为该对话框不是由页面上的 html 生成的。

c# selenium windows-authentication selenium-webdriver

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

Angular FormArray patchValue错误:TypeError:value.forEach不是函数 - 如何解决?

页面最初是作为模板驱动的表单编写的,但正在转换为被动,以便添加自动保存功能.

在页面组件的构造函数中,我定义了响应式表单变量:

 this.form = fb.group({
    reviewer: '',
    position: '',
    officeName: '',
    rows: fb.array([]),
    comments1: '',
    comments2: '',
    comments3: ''
});
Run Code Online (Sandbox Code Playgroud)

'rows'是与此问题相关的字段.

在ngInit中,通过web api发出请求以检索持久化的表单数据.数据作为行数组检索,每行包含6个单元格的数组.第三个单元格将绑定到FormControl,其他单元格将呈现为静态文本.

this.rows = summaryReportQuestion.map(summaryReportQuestionObj => {
    return {
        cells: [
            summaryReportQuestionObj.questionID,
            summaryReportQuestionObj.question,
            (summaryReportQuestionObj.columnSign == '$' ? (summaryReportQuestionObj.columnSign + ' ' + summaryReportQuestionObj.target) : summaryReportQuestionObj.target + ' ' + summaryReportQuestionObj.columnSign),
            (summaryReportQuestionObj.budget == null ? summaryReportQuestionObj.budget : (summaryReportQuestionObj.columnSign == '$' ? summaryReportQuestionObj.columnSign + ' ' + this.utilityService.formatNumberWithCommas(Math.floor(summaryReportQuestionObj.budget), false) : summaryReportQuestionObj.budget + ' ' + summaryReportQuestionObj.columnSign)),
            (summaryReportQuestionObj.average == null ? summaryReportQuestionObj.average …
Run Code Online (Sandbox Code Playgroud)

reactive-forms angular formarray

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