草庐IT

configure_permitted_parameters

全部标签

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# - .NET 自定义配置部分 : Configuration. GetSection 引发 'unable to locate assembly' 异常

我已经为一个插件DLL创建了一个自定义配置部分,它将.configXML存储在一个单独的(与主可执行应用程序不同的)文件中。这是自定义部分类的示例:usingSystem;usingSystem.Configuration;namespacePluginFramework.MyConfiguration{publicclassMyConfigurationSettings:ConfigurationSection{privateConfiguration_Config=null;#regionConfigurationProperties//////AcustomXMLsectionf

c# - 有没有办法根据任意 xml 获取 System.Configuration.Configuration 实例?

我正在尝试对我编写的自定义ConfigurationSection进行单元测试,我想将一些任意配置XML加载到System.Configuration.Configuration中对于每个测试(而不是将测试配置xml放在Tests.dll.config文件中。也就是说,我想做这样的事情:ConfigurationtestConfig=newConfiguration("...");MyCustomConfigSectionsection=testConfig.GetSection("mycustomconfigsection");Assert.That(section!=null);然

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# - 获取 "The WebResource.axd handler must be registered in the configuration to process this request."错误

我在IIS7上运行我的ASP.NET应用程序时遇到此错误。我已经尝试按照它说的去做,但没有帮助。TheWebResource.axdhandlermustberegisteredintheconfigurationtoprocessthisrequest.>>>>>>>>>我正在使用一点AJAX,我认为这是导致问题的原因。有人遇到过这个吗? 最佳答案 我想通了,所以出于搜索原因我将其张贴在这里。这是ASP.NET中的一个错误,它与安装ColdFusion有关。Microsoft尚未发布修复程序。有两种方法可以解决这个问题。将IIS7

C# : how to - single instance application that accepts new parameters?

我正在创建一个使用NZB文件下载二进制文件的(C#)程序,我的应用程序在任何时候可能只有一个实例在运行。因此,当用户双击.nzb文件并且我的程序未运行时,它应该启动并处理它(简单,文件注册)。现在,如果我的程序已经在运行,我不想启动第二个实例-我希望已经运行的实例获取指定的文件。可以使用带有.IsSingleInstance技巧的VisualBasicDLL使我的应用程序成为单一实例,但我不想去那里。正确的方法似乎是使用互斥锁来确保我的应用程序是单实例的,但现在我陷入了如何将指定参数(.nzb文件)传递给已经运行的实例的问题。帮助将不胜感激!:-) 最佳答案