草庐IT

user_set_flag

全部标签

c# - 将 'Set Next Statement' 强制为 'if' block 时出现 CLR System.NullReferenceException

背景我承认这不是正常代码执行期间可能发生的事情,但我在调试时发现了它,并认为它很有趣,可以分享。我认为这是由JIT编译器引起的,但欢迎任何进一步的想法。我已经使用VS2013复制了这个针对4.5和4.5.1框架的问题:设置要查看此异常,必须启用CommonLanguageRuntimeExceptions:DEBUG>异常...我已将问题的原因提炼为以下示例:usingSystem.Collections.Generic;usingSystem.Linq;namespaceConsoleApplication6{publicclassProgram{staticvoidMain(){v

c# - ASP.NET MVC : Problem setting the Authorize attribute Role from a variable, 需要常量

我在设置变量的授权属性角色值时遇到问题。错误消息说它需要一个const变量。当我创建一个const类型变量时,它工作正常,但我试图从Web.Config文件或任何其他允许最终用户设置它的文件加载值。我正在使用集成的Windows身份验证,因为这是一个仅限Intranet的应用程序。有没有办法从Controller检查用户角色?我将在if语句中使用它而不是属性来进行身份验证。[Authorize(Roles=Config.GMPUser)]publicActionResultIndex(){returnView();} 最佳答案 我有

c# - Properties.Settings.Default.Save(); ->那个文件在哪里

我有一个使用“设置”的应用。要保存我使用的设置:Properties.Settings.Default.Save();阅读我使用的:Properties.Settings.Default.MyCustomSetting;在我的应用程序文件夹中,我只有exe文件。没有配置文件。我的应用程序运行良好,可以读写设置。如果该文件不在应用程序文件夹中,该文件位于何处? 最佳答案 在我的WindowsXP机器上,设置保存在C:\DocumentsandSettings\\ApplicationData\下某处名为user.config的文件中。

c# - 为什么 EPPlus 告诉我 "Can' t set color when patterntype is not set"当我设置了 PatternType 时?

我有这段代码来尝试设置标题行的样式:worksheet.Cells["A32:D32"].Style.Font.Name="Georgia";worksheet.Cells["A32:D32"].Style.Font.Bold=true;worksheet.Cells["A32:D32"].Style.Font.Size=16;worksheet.Cells["A32:D32"].Style.Fill.PatternType=ExcelFillStyle.Solid;worksheet.Cells["A32:D33"].Style.Fill.BackgroundColor.SetCol

c# - 如何在设计时避免 XAML 代码中出现 "object reference not set to an instance of an object"异常?

我自己设计的wpf用户控件有问题。问题是,当我在我的程序中实现用户控件时,在设计时XAML代码中出现objectreferencenotsettoaninstanceofanobject异常。设计师向我展示了以下信息:atMicrosoft.Expression.Platform.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Typetype,BooleansupportInternal)atMicrosoft.Expression.Platform.InstanceBuilders.ClrObjectInstan

c# - 是否 (HttpContext.Current.User != null) 足以假设 FormsAuthentication 已对用户进行身份验证

在ASP.NET(2.0)应用程序中,我使用FormsAuthentication。在Global.asax/Application_AuthenticateRequest方法中,我检查HttpContext.Current.User是否为空。这是否足以了解表单例份验证cookie是否存在、票证是否过期以及表单例份验证机制是否已完成验证用户的工作?我需要这个,因为我在该应用程序中有某些页面,有时不需要访问身份验证(基于某些条件),我将它们放在web.config中的单独“位置”指令中,以便将它们从“捕获所有”表单例份验证中排除。即我正在尝试检查Application_Authentic

c# - x :Type not found in user control library

我正在尝试在WPF用户控件库项目中创建一个ResourceDictionary。当我添加以下样式时:我收到一条错误消息:Thetype'x:Type'wasnotfound.Verifythatyouarenotmissinganassemblyreferenceandthatallreferencedassemblieshavebeenbuilt.我将x声明为:xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"当我在WPF应用程序项目中而不是在UserControl库项目中创建资源字典时,这会起作用。知道为什么吗?

c# - Autofac - 自动注册错误 : No constructors can be found with 'Public binding flags'

这是我的Global.asax.cspublicvoidRegisterContainersUsingAutofac(){//http://elegantcode.com/2009/01/07/ioc-libraries-compared///http://www.codeproject.com/Articles/25380/Dependency-Injection-with-Autofac//https://code.google.com/p/autofac///http://api.autofac.org/varbuilder=newContainerBuilder();build

c# - 如何从 AD DirectoryEntry 获取 DOMAIN\USER?

如何从ActiveDirectoryDirectoryEntry(SchemaClassName="user")对象获取Windows用户和域?用户名在sAMAccountName属性中,但我可以在哪里查找域名?(我不能假设一个固定的域名,因为用户来自不同的子域。) 最佳答案 这假定results是从DirectorySearcher获得的SearchResultCollection,但您应该能够直接从DirectoryEntry获得objectsid。SearchResultresult=results[0];varpropert

c# - 如何为数组数据成员定义 get 和 set?

我正在创建一个类Customer,它具有以下数据成员和属性:privatestringcustomerName;privatedouble[]totalPurchasesLastThreeDays;//arrayof3elementsthatwillholdthetotalsofhowmuchthecustomerpurchasedforthepastthreedaysi.e.element[0]=100,element[1]=50,element[2]=250publicstringCustomerName{get{returncustomerName;}set{customerNa