.net-4.5

Decompressing password-protected ZIP files with .NET 4.5

杀马特。学长 韩版系。学妹 提交于 2019-12-17 16:15:47
问题 Microsoft introduces improvements for ZIP file handling in .NET 4.5 in the System.IO.Compression namespace. Namely the classes ZipArchive and ZipFile. However, I have not yet seen a way to use native .NET ZIP file handling for password protected files. Is there a way to achieve this? (I am aware that there are pretty good 3rd party zip file libraries, that is not the question.) 回答1: Unfortunately not. There is no support within the .Net Framework 4.5 for password protected zip files. In this

Brief explanation of Async/Await in .Net 4.5

谁说我不能喝 提交于 2019-12-17 15:42:08
问题 How does Asynchronous tasks (Async/Await) work in .Net 4.5? Some sample code: private async Task<bool> TestFunction() { var x = await DoesSomethingExists(); var y = await DoesSomethingElseExists(); return y; } Does the second await statement get executed right away or after the first await returns? 回答1: await pauses the method until the operation completes. So the second await would get executed after the first await returns. For more information, see my async / await intro or the official

.Net 4.5 WebSocket Server Running on Windows 7?

馋奶兔 提交于 2019-12-17 15:41:22
问题 I know the ClientWebSocket class of .Net 4.5 is not supported on Windows 7, but is it possible to create a WebSocket server running on Windows 7 using the .Net 4.5 API? To make myself clearer, according to both here and here, it looks like the server side part of the .Net 4.5 WebSocket implementation should be supported even on Windows 7, yet running a HttpListener and trying to access it using an open-source WebSocket implementation got me a "Portocol not supported" error 回答1: The OS-level

How do I timeout Regex operations to prevent hanging in .NET 4.5?

时光毁灭记忆、已成空白 提交于 2019-12-17 09:36:22
问题 There are times when being able to limit the pattern matching duration of regex operations could be useful. In particular, when working with user supplied patterns to match data, the pattern might exhibit poor performance due to nested quantifiers and excessive back-tracking (see catastrophic backtracking). One way to apply a timeout is to run the regex asynchronously, but this can be tedious and clutters the code. According to what's new in the .NET Framework 4.5 Developer Preview it looks

Is the CallerMemberName attribute in 4.5 “able to be faked”?

為{幸葍}努か 提交于 2019-12-17 09:35:50
问题 So .NET 4.5 introduces the CallerMemberNameAttribute , which seems like a godsend to anyone working with WPF and implementing INotifyPropertyChanged - my question is this: Is the attribute intrinsically tied/supported by the 4.5 5.0 compiler, or is it more of a syntactical sugar helper by the environment, much like one could fake out Visual Studio by declaring an ExtensionAttribute of your own, magically turning on LINQ syntax? Edit: (sorry Jon!) I guess I'm asking if one can "enable" the

Task.Yield - real usages?

六月ゝ 毕业季﹏ 提交于 2019-12-17 09:19:09
问题 I've been reading about Task.Yield , And as a Javascript developer I can tell that's it's job is exactly the same as setTimeout(function (){...},0); in terms of letting the main single thread deal with other stuff aka : "don't take all the power , release from time time - so others would have some too..." In js it's working particular in long loops. ( don't make the browser freeze... ) But I saw this example here : public static async Task < int > FindSeriesSum(int i1) { int sum = 0; for (int

HttpClient.GetAsync with network credentials

时间秒杀一切 提交于 2019-12-17 08:17:09
问题 I'm currently using HttpWebRequest to get a website. I'd like to use the await pattern, which is not given for HttpWebRequests . I found the class HttpClient , which seems to be the new Http worker class. I'm using HttpClient.GetAsync(...) to query my webpage. But I'm missing the option to add ClientCredentials like HttpWebRequest.Credentials . Is there any way to give the HttpClient authentication information? 回答1: You can pass an instance of the HttpClientHandler Class with the credentials

Differences between .NET 4.0 and .NET 4.5 in High level in .NET

放肆的年华 提交于 2019-12-17 08:07:49
问题 Eager to know Differences between .NET 4.0 and .NET 4.5 in High level in .NET and also differences in ASP.NET, C# also in these frameworks 回答1: What is new in .NET Framework 4.5 & What's new and expected in .NET Framework 4.5: Support for Windows Runtime Support for Metro Style Applications Support for Async Programming Garbage Collector Improvements Faster ASP.NET Startup Better Data Access Support WebSockets Support Workflow Support - BCL Support differences in ASP.NET in these frameworks

Differences between .NET 4.0 and .NET 4.5 in High level in .NET

感情迁移 提交于 2019-12-17 08:06:13
问题 Eager to know Differences between .NET 4.0 and .NET 4.5 in High level in .NET and also differences in ASP.NET, C# also in these frameworks 回答1: What is new in .NET Framework 4.5 & What's new and expected in .NET Framework 4.5: Support for Windows Runtime Support for Metro Style Applications Support for Async Programming Garbage Collector Improvements Faster ASP.NET Startup Better Data Access Support WebSockets Support Workflow Support - BCL Support differences in ASP.NET in these frameworks

Why does List<T> implement IReadOnlyList<T> in .NET 4.5?

末鹿安然 提交于 2019-12-17 07:41:30
问题 Why does List<T> implement IReadOnlyList<T> in .NET 4.5? List<T> isn't read only... 回答1: Because List<T> implements all of the necessary methods/properties/etc. (and then some) of IReadOnlyList<T> . An interface is a contract that says "I can do at least these things." The documentation for IReadOnlyList<T> says it represents a read-only collection of elements. That's right. There are no mutator methods in that interface. That's what read-only means, right? IReadOnlyList<T> is used in the