.net-4.0

Asp.Net 4.0 CacheItemPolicy sliding expiration incorrect?

时光毁灭记忆、已成空白 提交于 2019-12-08 16:27:33
问题 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Caching; using Xunit; namespace Demo.Caching.Test { class MemoryCacheManagerTest { [Fact] public void Test() { CacheItemPolicy policy = new CacheItemPolicy(); policy.SlidingExpiration = TimeSpan.FromSeconds(1); MemoryCache.Default.Set("cacheKey4", 4, policy); Assert.Equal(4, MemoryCache.Default.Get("cacheKey4")); System.Threading.Thread.Sleep(600); Assert.Equal(4, MemoryCache.Default.Get

C# Switch/case share the same scope? [duplicate]

半腔热情 提交于 2019-12-08 16:16:38
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Variable declaration in c# switch statement I've always wonderd : when i write : switch (temp) { case "1": int tmpInt = 1; break; } the case "1": region has a region of code which is executed ( until break) now , a waterfall from above can't get into a case of 2 e.g. : switch (temp) { case "1": int tmpInt = 1; case "2": break; } //error : break return is missing. So i assume , they have different regions of

Add a collection of a custom class to Settings.Settings

妖精的绣舞 提交于 2019-12-08 15:54:07
问题 I've been having a helluva time trying to add a custom collection of a custom class to the application settings of my winforms project I feel like Ive tried it about six different ways, including this way, this way, this way, and this way but nothing seems to work... Currently the code complies, and runs fine - no exceptions anywhere. Code his the Save function but no entries are created in the settings xml file (I have a few other settings and it works for all of them but this one FYI). When

Is it possible to have an out ParameterExpression?

自古美人都是妖i 提交于 2019-12-08 15:24:27
问题 I want to define a Lambda Expression with an out parameter. Is it possible to do it? Below are code snippets from a C# .Net 4.0 console app that I tried. As you can see in Procedure25 I can use lambda expressions to define a delegate that has an output parameter, however, when I want to use linq expressions to do the same, the code in procedure 24 fails with: System.ArgumentException was unhandled Message=ParameterExpression of type 'System.Boolean' cannot be used for delegate parameter of

WinForms - action after resize event

你。 提交于 2019-12-08 15:11:26
问题 Is it possible to perform a specific action after the resize event (of the user control), for example when mouse button is released? I need to manually resize an inner control and doing it on every single firing of the event would be quite, hmm, inefficient... 回答1: Just use the ResizeEnd event: private void Form1_ResizeEnd(object sender, EventArgs e) { // Your code here } From MSDN: The ResizeEnd event is raised when the user finishes resizing a form, typically by dragging one of the borders

How-to workaround differences with Uri and encoded URLs in .Net4.0 vs .Net4.5 using HttpClient

十年热恋 提交于 2019-12-08 15:02:49
问题 Uri behaves differently in .Net4.0 vs .Net4.5 var u = new Uri("http://localhost:5984/mycouchtests_pri/test%2F1"); Console.WriteLine(u.OriginalString); Console.WriteLine(u.AbsoluteUri); Outcome NET4.0 http://localhost:5984/mycouchtests_pri/test%2F1 http://localhost:5984/mycouchtests_pri/test/1 Outcome NET4.5 http://localhost:5984/mycouchtests_pri/test%2F1 http://localhost:5984/mycouchtests_pri/test%2F1 So when using the HttpClient distributed by Microsoft via NuGet requests like the above fail

Where is my GAC located?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 14:55:53
问题 I wanted to become more familiar with the .Net Global Assembly Cache. Various sources online say it can be found in Explorer in C:\WINNT\Assembly. But I don't seem to have a WINNT folder under C: on my Windows XP machine. I have "Show Hidden Files and Folders" checked and "Hide Protected Operating System Files" UN-checked. Using the methods described in How to detect what .NET Framework versions and service packs are installed? and especially in http://msdn.microsoft.com/en-us/kb/kbarticle

.NET 4.0 Memory Mapped Files Performance

时间秒杀一切 提交于 2019-12-08 14:42:11
问题 I'd like to know if anyone tried new .NET 4.0 Memory Mapped Files features? I know that they are as old as OS but native handling in .NET is new. Has anyone been able to test this and say something about performance? I'm quite interested in access time to random parts of binary file, write speed and so on. Also performance comparsion to native WinAPI MMF would be nice. Thanks! 回答1: Memory mapped files in .NET 4.0 (in the new System.IO.MemoryMappedFiles namespace) simply wrap the Win32 API for

After installing .NET 4.5, previous Unit-Test project fails to build

不打扰是莪最后的温柔 提交于 2019-12-08 14:36:08
问题 I have a .NET 4.0 WPF solution that includes a Unit Test project which tests the different commands used in the viewmodels. Everything was fine. Then I installed .NET framework 4.5 and then VS2012, and started getting error messages like - XYZProject.UsersViewModel_Accessor.AddUserToAccountsCommand' is not supported by the language Before installing VS2012 the UnitTestFramework.dll was referenced from - C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\ which was

Unlocking image from PictureBox

北战南征 提交于 2019-12-08 14:04:24
问题 I'm currently developing an application to help scanning and showing images here at my work. My application is build with multiple forms, the most important forms here is my mainForm to show statistics about the current scanning and a menustrip with different functinalities. I also have ImageViewerForm with a PictureBox which shows on the secondary monitor to view the current scanned image. I'm using a Timer to poll the folder where the images are scanned to. When a new image has been scanned