草庐IT

sync_fetch_and_add

全部标签

c# - 如果源绑定(bind)适用,如何访问快速访问工具栏命令 `Add to Quick Access Tool`

如果我已经为它绑定(bind)了集合,我该如何添加RibbonLibrary默认的快速访问项容器。当我从UI添加快速访问工具项时,它会抛出OperationisnotvalidwhileItemSourceisinuseinuse。ObservableCollection_MenuItems;ObservableCollection_QuickMenuItems;publicObservableCollectionMenuItems{get{return_MenuItems;}}publicObservableCollectionQuickMenuItems{get{return_Qu

c# - 为什么 Visual Studio IDE 有时会初始化“this.components 对象 : and other times not?

我最近注意到VisualStudioDesigner(C#)的一些我不理解的行为,想知道是否有人可以澄清...在我的一些Windows窗体中,设计器生成的代码的第一行是这样的;this.components=newSystem.ComponentModel.Container();在这种情况下,dispose方法在同一个设计器文件中,dispose方法在case“if”条件下放置两个“Dispose”调用,如下所示;protectedoverridevoidDispose(booldisposing){if(disposing&&(components!=null)){componen

c# - 错误 : ExecuteReader requires an open and available Connection. 连接的当前状态为打开

我有下面带有DataHelperClass的mvc4网站来执行查询。我的问题有时是,网站以异常为标题。我使用block来处理SqlCommand和SqlDataAdapter但没有成功。请帮助我,对不起我的英语。try{if(_conn.State==ConnectionState.Closed)_conn.Open();using(SqlCommandsqlCommand=newSqlCommand(query,_conn)){sqlCommand.CommandType=CommandType.StoredProcedure;if(parameters!=null)sqlComma

c# - 统一: Change default lifetime manager for implicit registrations and/or disable them

Unity容器将自动解析它可以自行识别的任何类型,无需手动注册。这在某些方面很好,但我遇到的问题是它使用TransientLifetimeManager来解决这种类型的问题,而我几乎总是想要一个ContainerControlledLifetimeManager。当然,我仍然可以手动将我的类型注册为单例,但如果我忘记了,应用程序将成功启动,而不是在启动时出现未处理的异常,并且一切似乎都正常工作。但最终会出现错误,可能非常微妙,难以诊断,因为存在一个类型的多个实例,这意味着是一个单例。所以我的问题是:有没有一种方法可以指定不同的默认生命周期管理器或完全禁用默认的自动解析行为并将容器限制为

c# - "Both use the XML type name X, use XML attributes to specify a unique XML name and/or namespace for the type"怎么解决?

我有以下枚举定义...namespaceItemTable{publicenumDisplayMode{Tiles,Default}}namespaceEffectiveItemPermissionTable{publicenumDisplayMode{Tree,FullPaths}}...然后我有以下类(class)...publicclassTablewhereTDisplayMode:struct{//publicpublicTDisplayModeDisplayMode{get{returnmDisplayMode;}set{mDisplayMode=value;}}//pri

c# - 类型 'TestClassAttribute' 存在于 'Microsoft.VisualStudio.QualityTools.UnitTestFramework and ' Microsoft.VisualStudio.TestPlatform.TestFramework

更新测试项目NuGet后出现此错误:Thetype'TestClassAttribute'existsinboth'Microsoft.VisualStudio.QualityTools.UnitTestFramework,Version=10.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'and'Microsoft.VisualStudio.TestPlatform.TestFramework,Version=14.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'

c# - GetMonthName : Valid values are between 1 and 13, 包括在内。为什么?

我不小心将0传递给DateTimeFormatInfo的GetMonthName方法:DateTimeFormatInfoinfo=newDateTimeFormatInfo();varmonthName=info.GetMonthName(0);并得到一个System.ArgumentOutOfRangeException错误消息:有效值在1到13之间,包括在内。传入1到12将返回“January”到“December”,但传入13将返回一个空字符串。我明白为什么月份数字不是零索引的,但是第13个月是做什么用的? 最佳答案 这是因

c# - 使用 "Expression Bodied Functions and Properties"有什么好处

这个问题在这里已经有了答案:Expression-bodiedfunctionmembersefficiencyandperformanceinC#6.0(2个答案)关闭6年前。我确实看到很多人使用该新功能,但使用这些表达式有什么好处?Examples:publicoverridestringToString()=>string.Format("{0},{1}",First,Second);publicstringText=>string.Format("{0}:{1}-{2}({3})",TimeStamp,Process,Config,User);这个问题不同于thisone,因为

c# - Children.Add(item) 值不在预期范围内

我正在开发Silverlight3应用程序,当我尝试将对象添加到Canvas时遇到这个非常奇怪的错误。我的代码如下:for(inti=0;i我第一次使用它时,它按预期工作。但是,当我在单击使用此代码创建的Person对象后点击x_LayoutRoot.Children.Add(child)时,我收到一个ArgumentException,告诉我“值不在预期范围内。”但是,当我在将child添加到x_LayoutRoot.Children之前添加以下代码时,问题就消失了。child.SetValue(Canvas.NameProperty,"child"+objCount++);为什么会

C#:Dictionary<K,V> 如何在没有 Add(KeyValuePair<K,V>) 的情况下实现 ICollection<KeyValuePair<K,V>>?

查看System.Collections.Generic.Dictionary,它清楚地实现了ICollection>,但没有所需的“voidAdd(KeyValuePairitem)”功能。这也可以在尝试初始化Dictionary时看到像这样:privateconstDictionaryPropertyIDs=newDictionary(){newKeyValuePair("muh",2)};失败了Nooverloadformethod'Add'takes'1'arguments为什么会这样? 最佳答案 预期的API是通过两个参数