.net-4.0

How to use WindowChrome without Windows Aero glass effects in wpf, black border

核能气质少年 提交于 2019-12-09 09:25:42
问题 I'm trying to customize a window border by using the WindowChrome class. Without Windows Aero glass effects. As expected I end up with a black boarder. But i also end up without caption buttons From Microsoft i learn that i can use the standard window by setting the window style to null to overcome these problem http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx But i do not succeed with that. Do anyone have a working example of this? Or a link of some sort that

String.Concat inefficient code?

回眸只為那壹抹淺笑 提交于 2019-12-09 07:46:10
问题 I was investigating String.Concat : (Reflector) very strange : the have the values array , they creating a NEW ARRAY for which later they send him to ConcatArray . Question : Why they created a new array ? they had values from the first place... edit code : public static string Concat(params string[] values) { if (values == null) { throw new ArgumentNullException("values"); } int totalLength = 0; string[] strArray = new string[values.Length]; for (int i = 0; i < values.Length; i++) { string

Specifying a Thread's Name when using Task.StartNew

萝らか妹 提交于 2019-12-09 07:34:56
问题 Is there a way to specify a Thread's name when using the Task.StartNew method var task = Task.Factory.StartNew(MyAction, TaskCreationOption.LongRunning, ??ThreadName??); 回答1: Not a Thread-name for sure. Threads and tasks are not 1-to-1 related. You can use the Task.Id to track it. 回答2: Well, this works: class Program { static void Main(string[] args) { var task = Task.Factory.StartNew(() => { Thread.CurrentThread.Name = "foo"; Thread.Sleep(10000); // Use Debug + Break to see it }); task.Wait(

Is there a way to do a PUT with WebClient?

时光总嘲笑我的痴心妄想 提交于 2019-12-09 07:27:18
问题 with the WebClient class in .NET 4.0, is there a way to do a PUT? I know you can do a GET with DownloadString() and a POST with UploadString(), but is there a method or property that lets you do a PUT? Thanks. 回答1: There are overloads for UploadString that let you specify the method. For example, this one takes a Uri , a string for the method, and a string for the data. 回答2: You can use webclient.UploadString(urlwithparams,"Put","") url with params should include the params in querystring

wpf toolkit rating size

偶尔善良 提交于 2019-12-09 03:51:26
问题 I'm using a rating control (from wpf toolkit) in my application. Is there any way I can scale this control? The rating stars are too big for my application.. I tried setting the height or width but that just cuts the stars but doens't resize them: Rating ratingControl = new Rating(); ratingControl .ItemsSource = ratingItems; ratingControl.Width = 50; ratingControl.Height = 10; // --> this doesn't change the size of the stars Greets Daan 回答1: i dont know the rating control, but if you wanna

Why does using ConfigurationManager.GetSection cause “SecurityException: Request failed” but ConfigurationManager.OpenExeConfiguration does not?

故事扮演 提交于 2019-12-09 02:49:28
问题 I have something curious that I am hoping a .Net expert can help me with. I have a custom configuration section and to get hold of it I do this: var s = (TestConfigurationSection)ConfigurationManager .GetSection("testSection"); I run that on my development machine ( Windows 7 , 64 bit, Windows completely up to date) and it works fine. I take the exe with that code in and I put it in a directory inside c:\users\public on a Windows Server 2008 R2 machine, open up a command prompt as

Create Hash Value on a List?

耗尽温柔 提交于 2019-12-09 02:36:43
问题 I have a List<MyRichObject> with 50 instances in it. Each of the instances has 1 or 2 unique properties, but in a way they are all unique because there is only one at position in the list, etc. I would like to come up with a unique way to "hash" this List so it is unique from all of the other Lists. Is there a smart way to do that in .NET 4? The purpose is to create a kind of "monniker" for the Lists so they can be dumped into a queue and found later based on their unique value. Thanks. 回答1:

Why does Task.Delay() allow an infinite delay?

人走茶凉 提交于 2019-12-09 00:28:37
问题 After my application froze I tracked down the cause to a thread waiting on a task created by Task.Delay() (or TaskEx.Delay() in .NET 4.0) for which it provided a computed TimeSpan that, due to a bug, was on occasion computed to a TimeSpan with a TotalMilliseconds of less than or equal to -1 and greater than -2 (i.e. anywhere between -10000 to -19999 ticks, inclusive). It appears that when you pass a negative TimeSpan that is -2 milliseconds or lower, the method correctly throws an

Problems with MembershipUser / System.Web.ApplicationServices when upgrading to .net 4

独自空忆成欢 提交于 2019-12-08 21:47:56
问题 I have a large vb.net web project that I am trying to updgrade to .net4/VS2010. During compile I get the following error: 'System.Web.Security.MembershipUser' in assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has been forwarded to assembly 'System.Web.ApplicationServices'. Either a reference to 'System.Web.ApplicationServices' is missing from your project or the type 'System.Web.Security.MembershipUser' is missing from assembly 'System.Web

CodeContracts: Possibly calling a method on a null reference

巧了我就是萌 提交于 2019-12-08 21:28:58
问题 I'm having an argument with the CodeContracts static analysis tool. My code: (ASCII version) The tool tells me that instance.bar may be a null reference. I believe the opposite. Who is right? How can I prove it wrong? 回答1: Update : It seems the problem is that invariants are not supported for static fields. 2nd Update: The method outlined below is currently the recommended solution. A possible workaround is to create a property for instance that Ensure s the invariants that you want to hold.