我正在运行Visual Studio 2012(版本11.0.61030.00更新4).调试本地控制台应用程序时,我在开始调试时遇到以下错误(F5):
---------------------------
Microsoft Visual Studio
---------------------------
Error while trying to run project: Unable to start debugging.
The object invoked has disconnected from its clients.
---------------------------
OK
---------------------------
Run Code Online (Sandbox Code Playgroud)
这种情况只有在我离开Visual Studio而没有调试几分钟时才会发生.如果我关闭视觉工作室并重新打开错误消失(直到我让它保持不动几分钟).有没有人经历过这个?我找不到其他人经历过的任何线索.
我有一个非常简单的PowerShell脚本(见下文).我在我的个人资料中使用以下内容获得了installutil别名:
set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
Run Code Online (Sandbox Code Playgroud)
在powershell中我简单地说:
installutil assemplylocation.dll
Run Code Online (Sandbox Code Playgroud)
这成功返回.(安装/提交都成功完成).然而,当我检查注册表时,或者在使用get-pssnapin -registered的powershell中,它没有显示我的程序集.我前几天做了这个,它工作正常,但我似乎无法复制它...请指教.
using System;
using System.Management.Automation;
using System.ComponentModel;
namespace PSBook_2_1
{
[RunInstaller(true)]
public class PSBookChapter2MySnapIn : PSSnapIn
{
public PSBookChapter2MySnapIn()
: base()
{ }
// Name for the PowerShell snap-in.
public override string Name
{
get
{
return "Wiley.PSProfessional.Chapter2";
}
}
// Vendor information for the PowerShell snap-in.
public override string Vendor
{
get
{
return "Wiley";
}
}
// Description of the PowerShell snap-in
public override string Description
{
get
{
return …Run Code Online (Sandbox Code Playgroud) 我有一个虚拟路径提供程序.问题是它缓存我的文件.每当我手动编辑其中一个aspx文件时,它引用VPP不会拉入新文件,它会继续重用旧文件,直到我重新启动站点.
我甚至在我的VirtualPathProvider类中过度使用了GetCacheDependency():
public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
return null;
}
Run Code Online (Sandbox Code Playgroud)
想法?
可能重复:
C#:等待所有线程完成
我有一个控制台应用程序产生一些线程,然后退出.每个线程大约需要20秒才能完成.似乎控制台应用程序正在生成线程,然后在线程有机会完成之前退出.
如何告诉控制台应用程序在它生成的所有线程完成之前不要退出?
我最好能告诉员工流程何时回收:
a)新的一个在旧的关闭之前旋转b)旧的一个关闭所有活动请求它的服务完成
以上是准确的吗?
如果是这样,一旦Application_End()从global.ascx文件触发,我就会在SQL中存储数据.当Application_Start()触发时,我将这些数据拉回来.
问题是基于我的测试,新的工作进程在我的旧工作进程有机会完成其Application_End()之前触发Application_Start().
处理这种情况的最佳做法是什么?
提前喝彩
编辑:我刚刚注意到IIS 7上的一个功能'禁用重叠回收' - 我猜这是最好的路线
我有一个命名缓存,只是想(以编程方式)返回其对象计数.
我有一个DataCache对象:cache = factory.GetCache("cacheName");
我目前正在尝试以下方法:cache.GetObjectsInRegion("cacheName").Count();
我意识到一个区域与命名缓存不同,但我没有看到任何其他方法可以让我实现这一点(虽然我确定有).有什么想法吗?
我刚刚在我的prod服务器上安装了AppFabric安装后,在我的开发环境中没有问题.AppFabric安装没有问题并且正在运行,但是当我尝试创建一个新的命名缓存(ps:New-Cache ClickUrls)时,我得到以下异常:
New-Cache:ErrorCode:SubStatus:错误:缓存创建返回失败.
在行:1 char:10
任何洞察它为什么不工作?这对我的开发环境来说不是问题.
提前喝彩
请原谅我下面的伪代码.我很确定有一种神奇的方法可以在单个linq语句中编写它,这也将大大提高性能.这里我列出了AList中的数百万条记录.id可能不是唯一的.我所追求的是原始列表删除所有重复项(基于id),但总是抓住最早的日期记录.当存在重复的id时,mystring几乎总是不同的值.
public class A
{
public string id { get; set; }
public string mystring { get; set; }
public DateTime mydate { get; set; }
}
List<A> aListNew = new List<A>();
foreach (var v in AList)
{
var first = AList.Where(d => d.id == v.id).OrderBy(d => d.mydate).First();
// If not already added, then we add
if (!aListNew.Where(t => t.id == first.id).Any())
aListNew.Add(first);
}
Run Code Online (Sandbox Code Playgroud)