草庐IT

input_parameter

全部标签

c# - 尝试打开 telerik 报告时出现 "Value cannot be null. Parameter name: instance"错误

在我的解决方案中,我有telerik报告,当尝试在VisualStudio2010设计器中打开它们时,我收到此错误:Valuecannotbenull.Parametername:instanceCallStackatSystem.ComponentModel.TypeDescriptor.AddAttributes(Objectinstance,Attribute[]attributes)atMicrosoft.VisualStudio.Design.VSDesignSurface.CreateDesigner(IComponentcomponent,BooleanrootDesig

c# - 我可以将 C# 函数标记为 "this function does not enumerate the IEnumerable parameter"吗?

同一可枚举的多次枚举对我们来说一直是一个性能问题,因此我们尝试在代码中消除这些警告。但是我们有一个通用的扩展函数来抛出空参数异常,它会生成很多这样的警告。它的签名看起来像这样:publicstaticvoidVerifyArgumentIsNotNull(thisTvalue,stringvalueName)whereT:class它所做的只是检查null并抛出一个格式良好且本地化(对于当时正在使用的任何人类语言)的异常。当此函数用于IEnumerable参数时,它会使代码分析警告IEnumerable可能的多次迭代,因为分析器不知道该函数的作用。我想在这个函数上加上一些标签,上面写着

c# - System.Drawing.Graphics.DrawString - "Parameter is not valid"异常

有时,Microsoft的异常消息毫无帮助,令人恼火。我创建了一个漂亮的小MVC方法来呈现文本。方法体如下。当它到达“DrawString”方法时,我得到一个异常抛出说“参数无效”。请注意,据我所知,字体构造正确(我只是使用10pt的Arial),矩形大小为正且看起来有效,画笔为白色SolidBrush,格式标志不影响输出;也就是说,如果我从调用中排除格式标志,我仍然会收到错误消息。DrawString调用就在底部附近。publicActionResultRenderText(stringfontFamily,floatpointSize,stringforeColor,stringb

c# - MVC 网络 API,错误 : Can't bind multiple parameters

传递参数时出错,"Can'tbindmultipleparameters"这是我的代码[HttpPost]publicIHttpActionResultGenerateToken([FromBody]stringuserName,[FromBody]stringpassword){//...}Ajax:$.ajax({cache:false,url:'http://localhost:14980/api/token/GenerateToken',type:'POST',contentType:"application/json;charset=utf-8",data:{userName

c# - 如何解决错误 : Inconsistent accessibility: parameter type for generic c# interface?

将此代码写入我的项目时出现错误Error1Inconsistentaccessibility:fieldtype'System.Collections.Generic.List'islessaccessiblethanfield'Jain_milan.addchild.m_children'Error2Inconsistentaccessibility:parametertype'System.Collections.Generic.List'islessaccessiblethanmethod'Jain_milan.addchild.addchild(System.Collectio

c# - 如何修复 'T' 是 'type parameter' 但被用作 'variable' 编译错误

我需要检查泛型类型参数T是MyEntity还是它的子类。下面的代码会导致这个编译器错误:'T'isa'typeparameter'butisusedlikea'variable'如何修复?publicclassMyEntity{}staticvoidTest(){//Error34'T'isa'typeparameter'butisusedlikea'variable'if(TisMyEntity){}} 最佳答案 您可以使用IsAssignableFromType上的方法检查是否有一个Type可以分配给另一个。if(typeof(

c# - "Possible multiple enumeration of IEnumerable"与 "Parameter can be declared with base type"

在Resharper5中,以下代码导致list出现警告“Parametercanbedeclaredwithbasetype”:publicvoidDoSomething(Listlist){if(list.Any()){//...}foreach(variteminlist){//...}}在Resharper6中,情况并非如此。但是,如果我将方法更改为以下内容,我仍然会收到该警告:publicvoidDoSomething(Listlist){foreach(variteminlist){//...}}原因是,在这个版本中,list只枚举一次,所以改成IEnumerable不会自动

c# - MSDeploy - 允许参数在 parameters.xml 中是可选的/为空的

我正在使用msdeploy部署asp.net-mvcWeb应用程序通过teamcity.我正在使用paramaters.xml文件来操纵我的应用程序的web.config,具体应用settings部分。我有一些设置,其中只有对特定环境具有值才有效,其余时间该值应为空白(即,Property应仅在Production上具有值)。但是,当我不指定一个值时,MSDeploy给了我这个异常:Microsoft.Web.Deployment.DeploymentException:The'facebookUserToken'argumentcannotbenullorempty.atMicros

c# - SQLCommand.Parameters.Add - 如何给出十进制值大小?

您将如何指定:Decimal(18,2)在此:SqlComm.Parameters.Add("@myValue",SqlDbType.Decimal,0,"myValue");目前我已经从设计端属性定义了precision=2。我只是好奇如何从代码中实现这一点。谢谢 最佳答案 没有Add的重载可让您直接设置小数精度,因此您需要创建一个SQlParameter对象并将其添加到集合中:SqlParameterparam=newSqlParameter("@myValue",SqlDbType.Decimal);param.SourceC

c# - 如何将字符转换为等效的 System.Windows.Input.Key 枚举值?

我想写一个这样的函数,publicSystem.Windows.Input.KeyResolveKey(charcharToResolve){//Codegoeshere,thatresolvesthecharToResolve//intotheKeyenumeratedvalue//(Forexamplewith'.'asthecharacterforKey.OemPeriod)}我知道我可以写一个巨大的Switch-case来匹配角色,但还有其他方法吗?问题是Key枚举的字符串可能与字符不匹配,因此Enum.IsDefined将不起作用有什么想法吗?更新:这是在Windows环境下