草庐IT

logical_not

全部标签

c# - ASP.NET/C# : DropDownList SelectedIndexChanged in server control not firing

我正在创建一个基本上绑定(bind)两个下拉列表的服务器控件,一个用于国家/地区,一个用于州,并在国家/地区的selectedindexchanged事件上更新州下拉列表。但是,它不会回发。任何想法为什么?将它们包装在UpdatePanel中的奖励积分(有渲染问题;可能是因为我没有要引用的页面?)这是我所拥有的(删除了一些额外的数据访问内容):publicclassStateProv:WebControl{publicstringSelectedCountry;publicstringSelectedState;privateDropDownListddlCountries=newDr

c# - MVC 全局错误处理 : Application_Error not firing

我正在尝试在我的MVC应用程序中实现全局错误处理。我的Application_Error中有一些逻辑重定向到ErrorController但它不起作用。我在Global.aspx的Application_Error方法中有一个断点。当我强制异常时,断点没有被击中。有什么想法吗? 最佳答案 您可以尝试使用这种方法进行测试:protectedvoidApplication_Error(objectsender,EventArgse){varerror=Server.GetLastError();Server.ClearError();R

c# - EntityFramework 测试初始化​​错误 : CREATE DATABASE statement not allowed within multi-statement transaction

我正在尝试构建一个快速测试,每次运行时都会删除并重新创建数据库。我有以下内容:[TestClass]publicclassPocoTest{privateTransactionScope_transactionScope;privateProjectDataSource_dataSource;privateRepository_repository=newRepository();privateconststring_cstring="DataSource=.;InitialCatalog=test_db;Trusted_Connection=True";[TestInitialize

c# - Facebook 登录抛出“应用程序配置不允许给定的 URL。: One or more of the given URLs is not allowed

我知道这个问题已经被问过很多次了,但是尽管我尝试了几个url地址,它似乎仍然会抛出这个错误。我正在尝试像微软教程中那样通过asp.netmvc应用程序登录facebookhere.当我在本地主机上检查它时它工作正常(Facebook中的站点URL设置为:http://localhost:55797/但是当我将应用程序上传到服务器后尝试检查它时,它给了我这个错误:GivenURLisnotallowedbytheApplicationconfiguration.:OneormoreofthegivenURLsisnotallowedbytheApp'ssettings.Itmustmat

c# - 通过安装程序设置模拟属性会导致 'Expression is not a method invocation'

我有下面的代码,其中我的Mock接口(interface)有一个Recorder属性,它是一个类。然后我尝试在该类上设置一个属性,但我得到了一个Expressionisnotamethodinvocation错误。你能帮忙吗?错误是在运行时尝试设置枚举属性时出现的。它会抛出一个带有以下堆栈跟踪的ArgumentException:atMoq.ExpressionExtensions.ToMethodCall(LambdaExpressionexpression)atMoq.Mock.c__DisplayClass1c`2.b__1b()atMoq.PexProtector.Invoke

c# - 错误 : The object cannot be deleted because it was not found in the ObjectStateManager

试图在这里处理EntityFramework,但我遇到了一些减速带......我有一个Get()方法可以正常工作并且已经过测试,但是我的Delete方法不起作用:publicstaticvoidDelete(stringname){J1Entitiesdb=newJ1Entities();db.DeleteObject(Get(name));db.SaveChanges();}但是我收到以下错误:错误:无法删除该对象,因为在ObjectStateManager中找不到它。我运行了调试器,DeleteObject中的对象是正确的...我错过了什么?谢谢。 最佳

c# - "The format of the URI could not be determined"与 WebRequest

我正在尝试使用C#中的WebRequest对站点执行POST。我发布到的站点是一个SMS站点,消息文本是URL的一部分。为了避免URL中出现空格,我调用HttpUtility.Encode()对其进行URL编码。但我不断收到URIFormatException-“无效的URI:无法确定URI的格式”-当我使用类似于此的代码时:stringurl="http://www.stackoverflow.com?question=asentencewithspaces";stringencoded=HttpUtility.UrlEncode(url);WebRequestr=WebReques

c# - ExecuteScalar 调用抛出异常 "Object reference not set to an instance of an object"

在单元测试中调试以下方法时出现以下错误Objectreferencenotsettoaninstanceofanobject点击以下行时result=(int)validateDatabase.ExecuteScalar();方法是publicstaticBooleanValidate(stringargument1,stringargument2){intresult=-1;using(varconnection=newSqlConnection("connectionstring")){SqlCommandvalidateDatabase=newSqlCommand("PROCED

c# - linq-to-sql "Cannot remove an entity that has not been attached"

当我尝试删除记录时出现错误Cannotremoveanentitythathasnotbeenattached.。我四处搜索,虽然有很多地方可以找到解决这个问题的方法,但建议的修复方法并没有让我更进一步:using(MyDataContextTheDC=newMyDataContext()){TheDC.MyTable.Attach(ARecord);//addedthislinebutdoesn'tfixit.TheDC.MyTable.DeleteOnSubmit(ARecord);TheDC.SubmitChanges();我更大的问题是:这个问题只影响删除查询还是影响其他类型的

c# - "StandardOut has not been redirected or the process hasn' t started yet”在 C# 中读取控制台命令输出时

感谢@user2526830提供的代码。基于该代码,我在程序中添加了几行,因为我想读取SSH命令的输出。下面是我的代码,它在while行出错StandardOuthasnotbeenredirectedortheprocesshasn'tstartedyet.我想要实现的是,我想将ls的输出读入一个字符串。ProcessStartInfostartinfo=newProcessStartInfo();startinfo.FileName=@"f:\plink.exe";startinfo.Arguments="-sshabc@x.x.x.x-pwabc123";Processproce