使用resharper从visual studio运行单元测试时出现以下错误:
Test-case objects missing for the following elements: ... Rebuild the project and try again
在单元测试方法旁边的工具提示中,它说:Inconclusive: Test not run
我认为它曾经说过Unit test skipped
.Resharper显示灰色眼睛图标.
Visual Studio的Test Explorer也存在一个奇怪的问题.它不会显示我的所有单元测试.事实上,它缺少200多个单元测试.它们只是没有出现在Test Explorer窗口中.我确实有一些测试出现并且运行得很好.
我已经尝试过的事情:重新启动我的机器,清理,重建,更改所有依赖项目以使用相同的.net框架4.7.
我正在使用VS 2017 .net Framework 4.7,Resharper和MSTest.全部包含最新的更新和版本.
我正在努力确定我们的Asp.net网站没有被搜索引擎索引的原因 - 整个网站.当我使用谷歌的"获取Googlebot"工具时,它会抛出以下错误.我确保我的网站可以禁用会话(即在web.config中设置sessionMode ="Off"),我已经在网上搜索过,但仍然没有运气.
这是我从googlebot得到的错误:
HTTP/1.1 302 Found
Date: Thu, 02 Dec 2010 23:05:49 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /ErrorPage.aspx?aspxerrorpath=/Default.aspx
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 168
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="%2fErrorPage.aspx%3faspxerrorpath%3d%2fDefault.aspx">here</a>.</h2>
</body></html>
Run Code Online (Sandbox Code Playgroud) 是的,这个问题类似于: How to log into separate files per thread with Log4Net? 除了直到运行时我不知道线程的数量或它们的名称。我的 Windows 应用程序为每个用户生成一个线程,为该用户执行长时间运行的工作。我想为每个用户/线程创建一个单独的日志文件。
log4net.Config.XmlConfigurator.Configure()?
(请详细说明如何实现日志记录。)
这是一个示例配置(我无法让 thread_name 属性与多个线程一起使用):
<log4net debug="false">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<!--need to replace LogDir in code like this: log4net.GlobalContext.Properties["LogDir"] = "c:\programdata\myapp"-->
<file type="log4net.Util.PatternString" value="%property{LogDir}\logs\mylogfile_%property{thread_name}.log" />
...
Run Code Online (Sandbox Code Playgroud)
和代码:
public class MyMultiThreadedClassForUsers
{
private log4net.ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void Start()
{
log4net.GlobalContext.Properties("LogDir") = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
log4net.Config.XmlConfigurator.Configure()
List<IUser> users = GetAllUsersFromDB();
foreach (IUser user in users) {
System.Threading.Thread t = new System.Threading.Thread(CallBackMethod);
t.Name = user.FirstName; …
Run Code Online (Sandbox Code Playgroud) Visual Studio中的Nuget无法访问共享网络驱动器上的自定义程序包源位置.我能够很好地浏览nuget.org和微软软件包.我无法浏览我们为自定义nuget包设置的本地网络共享.当我尝试时,我得到错误:
the path '\\someserver\somefolder' for the selected source could not be resolved
我可以通过资源管理器和映射驱动器访问文件位置.我尝试在nuget包管理器中删除并重新添加网络位置,但是当我尝试重新添加它时,我看不到映射的网络驱动器或使用完整的unc路径(它会引发错误,网络位置没有'存在).
nuget nuget-package nuget-package-restore visual-studio-2015
该FolderBrowserDialog
不会允许我浏览网络上的计算机,但它显示其他不必要的文件夹(我不希望本地文件夹).此外,我不想选择一个文件夹 - 只是计算机名称.
我知道你可以在不使用Invoke/BeginInvoke的情况下从工作线程读取gui控件,因为我的应用程序现在正在执行它.不会抛出跨线程异常错误,我的System.Timers.Timer线程能够很好地读取gui控件值(不像这个人:工作线程可以读取GUI中的控件吗?)
问题1: 鉴于线程的基本规则,我应该使用Invoke/BeginInvoke来读取表单控件值吗?这是否使它更安全?这个问题的背景源于我的应用程序遇到的问题.它似乎随机损坏另一个线程引用的表单控件.(见问题2)
问题2: 我有第二个线程需要更新表单控件值,所以我调用/ BeginInvoke来更新这些值.那么这个相同的线程需要对这些控件的引用,以便它可以更新它们.它包含这些控件的列表(比如DataGridViewRow对象).有时(并非总是),DataGridViewRow引用变得"损坏".我的意思是腐败,是引用仍然有效,但一些DataGridViewRow属性为null(例如:row.Cells).这是由问题1引起的,还是可以给我任何关于为什么会发生这种情况的提示?
这是一些代码(最后一行有问题):
public partial class MyForm : Form
{
void Timer_Elapsed(object sender)
{
// we're on a new thread (this function gets called every few seconds)
UpdateUiHelper updateUiHelper = new UpdateUiHelper(this);
// Is it thread-safe to step through the datagrid rows here without invoking?
foreach (DataGridViewRow row in dataGridView1.Rows)
{
object[] values = GetValuesFromDb();
updateUiHelper.UpdateRowValues(row, values[0]);
}
// .. do other work here
updateUiHelper.UpdateUi();
}
}
public class UpdateUiHelper
{
private readonly Form …
Run Code Online (Sandbox Code Playgroud) 我有一个试图在我的web.config中更改URL值的nant脚本但是Nant一直在抛出这个错误:
'=' is an unexpected token. The expected token is ';'. Line 1, position 80.
Run Code Online (Sandbox Code Playgroud)
我将其追溯到nant脚本的URL中的分号.我首先在URL中使用分号的原因是因为web.config不喜欢&符号(&).所以我不得不替换和&
.这是我的web.config值:
<appSettings>
<add key="myUrl" value="http://www.google.com/whatever?id=myId&fullScreen=1"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我能够在web.config中xmlpo所有其他"添加键"但是这个,所以它不是一个xpath问题.这是nant脚本:
<property name="myUrl" value="http://www.google.com/whatever?id=123456&fullScreen=2"/>
<xmlpoke
file="${config.file}"
xpath="/configuration/appSettings/add[@key = 'myUrl']/@value"
value="${myUrl}">
</xmlpoke>
Run Code Online (Sandbox Code Playgroud)
所以问题不在于web.config中的分号,而是在nant脚本中使用分号.我想我需要以某种方式逃避nant脚本中的分号.任何人都知道如何做到这一点或其他什么来让它工作?
我的目标是通过表tbl递归,并在通过该表递归时从另一个表tbl2中选择一个国家缩写(如果它存在)并将这些结果附加到最终输出中.
我将使用的例子来自这篇文章
tbl2有一个外键'tbl_id'到tbl,看起来像这样
INSERT INTO @tbl2( Id, Abbreviation, tbl_id )
VALUES
(100, 'EU', 1)
,(101, 'AS', 2)
,(102, 'DE', 3)
,(103, 'CN', 5)
Run Code Online (Sandbox Code Playgroud)
*注意:并非所有国家/地区都有缩写.
诀窍是,我希望亚洲所有国家至少显示亚洲的缩写"亚洲",即使一个国家没有缩写(例如印度).如果该国家确实有缩写,则结果需要如下所示:中国:CN,AS
我使用子查询部分工作,但印度总是为缩写返回NULL.它的行为就像没有完整的递归路径回到缩写,然后它返回null.也许解决方案是在缩写表上使用左外连接?我已经尝试了几个小时的许多不同的变化,子查询尽可能接近我.
WITH abcd
AS (
-- anchor
SELECT id, [Name], ParentID,
CAST(([Name]) AS VARCHAR(1000)) AS "Path"
FROM @tbl
WHERE ParentId IS NULL
UNION ALL
--recursive member
SELECT t.id, t.[Name], t.ParentID,
CAST((a.path + '/' + t.Name + ':' +
(
select t2.abbreviation + ','
from @tbl2
where t.id = t2.id
)) AS VARCHAR(1000)) AS …
Run Code Online (Sandbox Code Playgroud) 我写了一个简单的控制台应用程序,以测试基于Microsoft在msdn上的示例的Parallel.Invoke的性能:
public static void TestParallelInvokeSimple()
{
ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 1 }; // 1 to disable threads, -1 to enable them
Parallel.Invoke(parallelOptions,
() =>
{
Stopwatch sw = new Stopwatch();
sw.Start();
Console.WriteLine("Begin first task...");
List<string> objects = new List<string>();
for (int i = 0; i < 10000000; i++)
{
if (objects.Count > 0)
{
string tempstr = string.Join("", objects.Last().Take(6).ToList());
objects.Add(tempstr + i);
}
else
{
objects.Add("START!");
}
}
sw.Stop();
Console.WriteLine("End first task... {0} seconds", sw.Elapsed.TotalSeconds);
}, …
Run Code Online (Sandbox Code Playgroud)