.net

Unable to remove list item from list inside a for each loop C# [duplicate]

自闭症网瘾萝莉.ら 提交于 2021-02-11 17:26:14
问题 This question already has answers here : What is the best way to modify a list in a 'foreach' loop? (11 answers) Closed 6 years ago . I have a list of custom objects named _interestlist . Now I want to remove all the items in this list which have "active" member is set to false. and I wrote some thing like this int counter = 0; foreach (var interest in _interestlist) { if (interest.active==false) { _interestlist.Remove(interest); } counter++; } But this throws an error like this Collection

fire panel events for child controls

我只是一个虾纸丫 提交于 2021-02-11 17:23:02
问题 I have a Panel named panel1. panel1 has a "mosuseHover" eventhandler .panel1 also has some controls like pictureBox , label etc. When i move mouse on panel1 , the event fire correctly , but when the mouse courser goes on panel1 controls , like pictureBox , the event not work . how can i make event to be invoke when mouse courser is on child controls. I should note that i dont want create eventhandler for each child contol. Best Regards 回答1: You can add an IMessageFilter to implement your own

Searching entire computer for specified file

女生的网名这么多〃 提交于 2021-02-11 17:22:28
问题 Is there a way to search the entire computer and get the full file path of specified file, given a filename to match against? If you enter for example "file.dat" in textbox it show you full file path if it exist? 回答1: Look into the Directory class in System.IO . Whichever solution you use, avoid using GetFiles() instead use EnumerateFiles() since EnumerateFiles() is recommended for large arrays. (In your case the entire C drive) As per the MSDN documentation: Enumerable collections provide

fire panel events for child controls

核能气质少年 提交于 2021-02-11 17:22:12
问题 I have a Panel named panel1. panel1 has a "mosuseHover" eventhandler .panel1 also has some controls like pictureBox , label etc. When i move mouse on panel1 , the event fire correctly , but when the mouse courser goes on panel1 controls , like pictureBox , the event not work . how can i make event to be invoke when mouse courser is on child controls. I should note that i dont want create eventhandler for each child contol. Best Regards 回答1: You can add an IMessageFilter to implement your own

Why deserialize XML into Object return null value?

谁都会走 提交于 2021-02-11 16:55:02
问题 I have a XML string like that: <?xml version="1.0" ?> <result> <vmeet_id>7121</vmeet_id> <username>MT_Hue_QuangBinh_QuangTri</username> <email></email> <begin_date>2010-04-21 08:53</begin_date> <expiry_date>2010-12-21 00:00</expiry_date> <point></point> <info>OK</info> </result> I want to deserialize it into an object, so I created this class: [Serializable] [XmlRoot(ElementName = "result", IsNullable = false)] public class UserInfo { [XmlAttribute("vmeet_id")] public int UserID { get; set; }

Why deserialize XML into Object return null value?

我是研究僧i 提交于 2021-02-11 16:54:47
问题 I have a XML string like that: <?xml version="1.0" ?> <result> <vmeet_id>7121</vmeet_id> <username>MT_Hue_QuangBinh_QuangTri</username> <email></email> <begin_date>2010-04-21 08:53</begin_date> <expiry_date>2010-12-21 00:00</expiry_date> <point></point> <info>OK</info> </result> I want to deserialize it into an object, so I created this class: [Serializable] [XmlRoot(ElementName = "result", IsNullable = false)] public class UserInfo { [XmlAttribute("vmeet_id")] public int UserID { get; set; }

Cannot redirect back to angular client after login in identity server

元气小坏坏 提交于 2021-02-11 16:28:00
问题 I've got an issue with redirecting after loggin in with identity server. I have the following angular-auth-oidc-client config: export function configureAuth(oidcConfigService: OidcConfigService) { return () => oidcConfigService.withConfig({ stsServer: 'http://localhost:5002', redirectUrl: window.location.origin, postLogoutRedirectUri: window.location.origin, clientId: 'applications-portal', scope: 'openid profile', responseType: 'id_token token', logLevel: LogLevel.Debug, }); } And app

DateTime format debugging

对着背影说爱祢 提交于 2021-02-11 15:55:53
问题 So I have been struggling with DateTime formats. I am making an ASP.NET MVC app and I have a DateOfBooking property which is DateTime type. This property books DateTime.Date.Now when the form is sent. Below is my property and DataAnotations used to format my date. Format which i need is dd/MM/yyyy, but my column in DB (MS SQL Server Managment Studio) is in format yyyy-MM-dd. [DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] public

SqlException: Login failed for user 'DOMAIN\MACHINENAME$' for SQL Server with .NET Core 2.1

谁都会走 提交于 2021-02-11 15:51:47
问题 Here is the contents of my connection string. It is an .NET Core 2.1 web application. When I run on my PC, it works fine. When I deploy it to IIS and run it, this error will occur. The detailed error is after the appsetting. "Testing2012Context": "Server=Server;Database=Testing2012;User ID=User;Password=Pwd;Trusted_Connection=False;MultipleActiveResultSets=true" Error: SqlException: Login failed for user 'DOMAIN\MACHINENAME$' for the SQL Server with .NET Core 2.1 ... System.Data.SqlClient

SqlException: Login failed for user 'DOMAIN\MACHINENAME$' for SQL Server with .NET Core 2.1

二次信任 提交于 2021-02-11 15:49:55
问题 Here is the contents of my connection string. It is an .NET Core 2.1 web application. When I run on my PC, it works fine. When I deploy it to IIS and run it, this error will occur. The detailed error is after the appsetting. "Testing2012Context": "Server=Server;Database=Testing2012;User ID=User;Password=Pwd;Trusted_Connection=False;MultipleActiveResultSets=true" Error: SqlException: Login failed for user 'DOMAIN\MACHINENAME$' for the SQL Server with .NET Core 2.1 ... System.Data.SqlClient