草庐IT

The_constant_pool

全部标签

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# - 创建成员(member)用户时出错 "The password-answer supplied is invalid"

这个问题在这里已经有了答案:ASP.NETMembershipCreateUserwithoutrequiresQuestionAndAnswer(3个答案)关闭7年前。我尝试使用CreateUser方法创建一个新用户。但是当我点击创建用户按钮时,我得到了这个奇怪的错误:“提供的密码答案无效”。我已经尝试输入强密码(123$567)或普通密码(1234)。我怀疑它与密码强度有什么关系,因为那会引发不同的异常。这是我的代码:Membership.CreateUser(username,password);谁能告诉我为什么会这样?

C# 错误 : The call is ambiguous between the following methods or properties. 运算符重载

我在名为Dinero的命名空间中有2个带有重载运算符的类,这些是2个类:第一个:namespaceDinero{classDollar{#regionAtributospublicDoublecant;#endregion#regionConstructorespublicDollar(){this.cant=0;}publicDollar(Doubleamount){this.cant=amount;}#endregion#regionSobrecargadeOperadorespublicstaticDollaroperator+(Euroeu,Dollardol){Dollard

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# - 无法从传输连接读取数据 : The connection was closed error in console application

我在控制台应用程序中有这段代码,它在一个循环中运行try{HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(search);request.Headers.Add("Accept-Language","de-DE");request.Method="GET";request.Accept="text/html";using(HttpWebResponseresponse=(HttpWebResponse)request.GetResponse()){using(StreamReaderreader=newStreamRead

c# - 如何解决 "The ChannelDispatcher is unable to open its IChannelListener"错误?

我正在尝试在Windows服务中托管的WCF和我的服务GUI之间进行通信。问题是当我尝试执行我得到的OperationContract方法时"TheChannelDispatcherat'net.tcp://localhost:7771/MyService'withcontract(s)'"IContract"'isunabletoopenitsIChannelListener."我的app.conf看起来像这样:端口7771正在监听(使用netstat检查)并且svcutil能够为我生成配置。如有任何建议,我们将不胜感激。异常的堆栈跟踪Serverstacktrace:atSyste

c# - 误报 : Fix this implementation of IDisposable to conform to the dispose pattern

我的类实现了IDisposable并遵循了的模式publicvoidDispose(){Dispose(true);GC.SuppressFinalize(this);}但sonar仍然告诉我需要实现处置模式...https://sonarqube.com/issues#issues=AVtsPLjmtpYg8Dj4z0MU这是Sonar的缺陷还是我遗漏了什么? 最佳答案 我看到你已经解决了这个问题,但如果其他人有同样的问题,我会详细说明规则要求。这条规则的想法是允许潜在的派生类正确地处理你的类的成员。因此,如果您的类是密封的,则该

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

c# - Lazy<T> 延迟加载错误 : A field initializer cannot reference the non-static field, 方法或属性

我第一次尝试使用延迟加载来初始化我的类中的进度对象。但是,我收到以下错误:Afieldinitializercannotreferencethenon-staticfield,method,orproperty.privateLazym_progress=newLazy(()=>{longtotalBytes=m_transferManager.TotalSize();returnnewProgress(totalBytes);});在.NET2.0中,我可以执行以下操作,但我更愿意使用更新的方法:privateProgressm_progress;privateProgressPro

c# - "Items collection cannot be modified when the DataSource property is set."

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭11年前。通过表单将文件添加到txt文件的程序有这个问题,但这个问题没有说明Fstream的任何内容,所以我认为它不必处理它,但我不确定是什么这个问题的意思是。lstEmployees.Items.Add("Norecordsfound.");