.net-4.0

Draw border for NumericUpDown

妖精的绣舞 提交于 2021-02-19 06:13:36
问题 I have an user form in application. Some fields are validated. If field has wrong value red border is drawn for this control. It is made by handling Paint event for this control. I extended TextField and DateTimePicker to get Paint event from those classes objects. I have problem with NumericUpDown class. It does fire Paint event properly but invoking ControlPaint.DrawBorder(e.Graphics, eClipRectangle, Color.Red, ButtonBorderStyle.Solid); does completely nothing. Any ideas or suggestions? If

Best way to check if a byte[] is contained in another byte[] [duplicate]

我的梦境 提交于 2021-02-19 05:41:27
问题 This question already has answers here : Closed 10 years ago . Possible Duplicate: byte[] array pattern search Hello, Whats the best way to search if a byte[] is in another byte[]. For example byte[] first = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }; byte[] second = new byte[] { 0x01, 0x02 }; byte[] third = new byte[] { 0x01, 0x03 }; The method would return: first.Contains(second); // true first.Contains(third); // false second.Contains(third); // false Thanks! 回答1: you could use Jb's

Using the .NET 4 Task library to display a blocking message box in WPF

有些话、适合烂在心里 提交于 2021-02-19 02:47:07
问题 I have the following code in my WPF application: Task task = Task.Factory.StartNew(() => { DoInitialProcess(); }); task.ContinueWith(t => Dispatcher.BeginInvoke((Action)(() => { MessageBox.Show("Error: " + t.Exception.InnerExceptions[0].Message); })), TaskContinuationOptions.OnlyOnFaulted); It successfully triggers the continuation and displays the message box if an exception occurs, but it does not block input on the main UI thread. Why doesn't it block the main UI thread, and what is the

How to update UI (text fields) during long running function?

佐手、 提交于 2021-02-18 17:38:07
问题 I know that the question may not make sense, and I'm having a tough time trying to think of a way to explain it, so I will show a snippet of code to help. I'm using Winforms on visual studio express 2010: private void button1(object sender, EventArgs e) { txtOutput.Text += "Auto-collecting variables. This may take several minutes"; string v = foo(); txtOutput.Text += "\n" + v; string b = bar(); txtOutput.Text += "\n" + b; txtOutput.SelectionStart = txtOutput.Text.Length; txtOutput

how to use app.config on the DLL instead of exe

落花浮王杯 提交于 2021-02-18 08:20:17
问题 This is a sister question along with my first question Allow C# application built with .NET 2.0 to run on .NET 4.0/4.5. I simplified my situation a little bit there for understanding. Actually our case is a little special. Basically we wrote a C# DLL (Let's call E.dll ) for our MSI installer. Since our MSI installer is using older version of windows installer, it could not use C# DLL directly and it could only work with C type DLL, so we use an open source library called DLLExporter to

Null reference - Task ContinueWith()

爷,独闯天下 提交于 2021-02-16 18:23:11
问题 For the following piece of code (.NET v4.0.30319) I am getting a null reference exception indicated below in the second continuation. Most interestingly this issue has only occurred in machines with 8GB RAM but other users have 16GB and more and they haven't reported any issue, and it is a very intermittent issue which leads me to suspect a garbage collection issue. The GetData() can be called multiple times so the first continuation of _businessObjectTask will only be called once as

C# compile errors in unsafe code

徘徊边缘 提交于 2021-02-11 15:52:08
问题 Compiling a VS 2010 c# project (.NET 4.0, any CPU, allow unsafe code = checked) we are getting a variety of compile errors as below: Operator '*' cannot be applied to operands of type 'System.IntPtr' and 'int' Constant value '325486741' cannot be converted to a 'int' (use 'unchecked' syntax to override) Cannot convert type 'string' to 'char*' Cannot implicitly convert type 'long' to 'byte*'. An explicit conversion exists (are you missing a cast?) Invalid expression term 'ref' All these are

C# compile errors in unsafe code

一曲冷凌霜 提交于 2021-02-11 15:51:09
问题 Compiling a VS 2010 c# project (.NET 4.0, any CPU, allow unsafe code = checked) we are getting a variety of compile errors as below: Operator '*' cannot be applied to operands of type 'System.IntPtr' and 'int' Constant value '325486741' cannot be converted to a 'int' (use 'unchecked' syntax to override) Cannot convert type 'string' to 'char*' Cannot implicitly convert type 'long' to 'byte*'. An explicit conversion exists (are you missing a cast?) Invalid expression term 'ref' All these are

C# compile errors in unsafe code

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 15:51:01
问题 Compiling a VS 2010 c# project (.NET 4.0, any CPU, allow unsafe code = checked) we are getting a variety of compile errors as below: Operator '*' cannot be applied to operands of type 'System.IntPtr' and 'int' Constant value '325486741' cannot be converted to a 'int' (use 'unchecked' syntax to override) Cannot convert type 'string' to 'char*' Cannot implicitly convert type 'long' to 'byte*'. An explicit conversion exists (are you missing a cast?) Invalid expression term 'ref' All these are

Process.Start and “The system cannot find the path specified”

不想你离开。 提交于 2021-02-11 15:14:26
问题 I am trying to run a console application from a mapped drive (T:\ is a mapped drive for a shared network folder) and get the error: The system cannot find the path specified. Why do I get this error? The administrator credentials are correct. var password = new SecureString(); password.AppendChar(Convert.ToChar("P")); password.AppendChar(Convert.ToChar("a")); password.AppendChar(Convert.ToChar("a")); password.AppendChar(Convert.ToChar("s")); Process.Start(@"t:\ca\test.exe"), "",