.net-4.5

How to Convert IPicture to Image - .NET 4.5 TagLib Sharp

ⅰ亾dé卋堺 提交于 2019-12-10 06:26:52
问题 I am wanting to display the album artwork of a song (accessed via the taglib-sharp library) within a Windows Forms picture box. The problem I'm running into is that the taglib-library returns an image of type TagLib.IPicture whereas the picture box requires an object of type System.Drawing.Image . I have scoured the internet for many hours now, looking for a way to convert from an IPicture to Image , but to no avail. The best lead I have is this: http://msdn.microsoft.com/en-us/library/system

Change .NET Framework Target of Compiled Executable

杀马特。学长 韩版系。学妹 提交于 2019-12-10 06:26:20
问题 As Windows 8 doesn't contain .NET 2/3.5 by default, I would like to convert some .NET 2.0 compiled executables to .NET 4.5 without re-compiling them with VS 2012. Is there an utility for this task? 回答1: You could just create or modify the app.config file, and set the supportedRuntime element to 4.5. This will cause the 4.0 CLR (which will use the 4.5 framework) to load the assembly, and does not require any change to the executable itself. 回答2: As additional information (the solution provided

Why does the localInit Func get called multiple times per thread in Parallel.ForEach

自闭症网瘾萝莉.ら 提交于 2019-12-10 03:54:42
问题 I was writing some code to process a lot of data, and I thought it would be useful to have Parallel.ForEach create a file for each thread it creates so the output doesn't need to be synchronized (by me at least). It looks something like this: Parallel.ForEach(vals, new ParallelOptions { MaxDegreeOfParallelism = 8 }, ()=>GetWriter(), // returns a new BinaryWriter backed by a file with a guid name (item, state, writer)=> { if(something) { state.Break(); return writer; } List<Result> results =

ASP.NET EventValidation fails when .NET 4.5 Framework is installed in only one server behind the load balancer

末鹿安然 提交于 2019-12-10 03:39:43
问题 We have installed .net 4.5 Framework in one of our web servers. Our applications are targeted for .net 4.0 and run off multiple servers behind a load balancer. After the installation we get the following error message for some POST requests error_name=System.ArgumentException error_message=Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments

Uri.EscapeUriString with square braces

让人想犯罪 __ 提交于 2019-12-10 03:34:07
问题 Something of a strange question but let's see what kind of response it gets... If I code a console app (VS 2013, .NET 4.5.1) and execute this line of code: Uri.EscapeUriString("[") I get this: [ However if I execute the same thing (well, technically Uri.EscapeUriString("[").Dump() ) in LINQPad on my machine I get this: %5B To further complicate things, according to this post Uri.EscapeUriString("[") should indeed return %5B .The post was written on 27/06/2012. I'm thinking that perhaps

WPF Maximized Window bigger than screen

穿精又带淫゛_ 提交于 2019-12-10 02:21:46
问题 When creating a WPF window with AllowsTransparency="True" WindowStyle="None" and maximizing it via this.WindowState = WindowState.Maximized; the Window gets bigger than my screen. When setting AllowTransparency="False" i have a border around my Window, but the window won't get bigger than my screen. In my Case I have a 1920x1080 screen and the window becomes 1934x1094. On my 1280x1024 screen the window will become 1294x1038. The Window will become still as big as this, whether or not

Execution-Deferred IQueryable<T> from Dynamic Linq?

痴心易碎 提交于 2019-12-10 01:59:04
问题 I am using Dynamic Linq to perform some queries (sorry but it's my only option). As a result, I am getting an IQueryable instead of an IQueryable<T> . In my case, I want an IQueryable<Thing> where Thing is a concrete type. My query is as such: public IQueryable<Thing> Foo(MyContext db) { var rootQuery = db.People.Where(x => x.City != null && x.State != null); var groupedQuery = rootQuery.GroupBy("new ( it.City, it.State )", "it", new []{"City", "State"}); var finalLogicalQuery = groupedQuery

Writing a Task.WhenAll/WhenAny variant that cancels all other tasks on first faulted/Cancelled task

心不动则不痛 提交于 2019-12-09 23:20:21
问题 I'm fairly new to C# and started playing around with the TPL today. I decided to write a modified version of Task Task.WhenAll as an exercise. I'd like for it to have the following behavior: Upon finding the first task that has faulted or been canceled, cancel the rest of the tasks instead of waiting for them to finish. If the task faulted, the returned task should have the right exception set (i.e no swallowing by continuation and replacing with OperationCancelledException()) No async in the

Writing to the console using Task.Run() fails

北战南征 提交于 2019-12-09 14:48:00
问题 A colleague of mine found an issue with our code and it took a while to hunt down exactly what was happening, but it can be best demonstrated by this simple example: // Fails class Program { static void Main(string[] args) { Task.Run(() => Console.WriteLine("Hello World")); Console.ReadKey(); } } // Works fine class Program { static void Main(string[] args) { Console.Write(String.Empty); Task.Run(() => Console.WriteLine("Hello World")); Console.ReadKey(); } } It’s clear from playing around

C# 5.0 async await return a list

女生的网名这么多〃 提交于 2019-12-09 13:15:55
问题 I'm learning about async/await, and ran into a situation where I need to call an async method that should return an object or list of same object. Is this the right way to implement ? from AManager.cs public async Task Initialize(string objectPath) { AnObject someObject = await BClass.GetAnObject(objectPath); } and this is the called method Class B: public async Task<AnObject> GetAnObject(string objectPath) { AnObject someObj = new AnObject(); return someObj; } What happens if I want to