.net-4.0

Recursive linq and this?

人走茶凉 提交于 2019-12-11 00:59:39
问题 I want to find all Persons who are left handed using recursive linq via extension method. I've seen this answer but there is a problem (imho) with the this : (when applied as extension method because of the static context) keyword this is not valid in static method So here is what i've tried : I have a Person class : public class Person { public List<Person> Children = new List<Person>(); public bool IsLeftHanded; } And here is the code for the externsion method : public static class

Does Task.RunSynchronously() work “recursively”?

怎甘沉沦 提交于 2019-12-11 00:53:31
问题 If I call RunSynchronously() on a Task in C#, will this lead to asynchronous calls further down the rabbit hole to be run synchronously as well? Let's say I have a method named UpdateAsync() . Inside this method another asynchronous call is made to DoSomethingAsync() and inside this again we find DoSomethingElseAsync() , will calling RunSynchronously() on 'UpdateAsync()' lead to RunSynchronously() also indirectly being called on DoSomethingAsync() ? The reason for my question: I have a

.NET 4.0 framework on same server as .NET 1.1

人盡茶涼 提交于 2019-12-11 00:52:56
问题 Can these framework versions work and play well on the same server? Meaning that can IIS support two application pools where one pool is configured with .NET 4.0 and the other with .NET 1.1. EDIT: This question is concerned with IIS 7. 回答1: Yes, you can have 1.1, 2.0 and 4.0 CLRs all running in the same IIS instance, they are intentionally side-by-side installs to facilitate this, you'll have 3 options in the dropdown for your application pool .Net versions, one for each CLR version. 回答2: yes

Determine type from given string input

空扰寡人 提交于 2019-12-11 00:50:45
问题 Is there any way to detect the type from a given string input? Eg: string input = "07/12/1999"; string DetectType( s ) { .... } Type t = DetectType(input); // which would return me the matched datatype. i.e. "DateTime" in this case. Would I have to write this from scratch? Just wanted to check if anybody knows of a better way before I went about it. Thanks! 回答1: I'm pretty sure you'll have to write this from scratch - partly because it's going to be very strictly tailored to your requirements

Simple app using Windows Workflow and winforms NOT console

北战南征 提交于 2019-12-11 00:31:53
问题 I'm looking for a simple starter app that allows you to type in a value 1 - 10 this value is passed to a WF rule that evaluates if it is greater, less than or equal to 5 and returns the results to the windows forms app which displays the results in a label. I can find a lot of .net 3.5 console app tutorials but nothing that shows how to pass into and receive the result back using windows forms and .net 4! it doesn't need to be the above example but it needs to show me how to pass a value into

The new IntPtr.Add method - am I missing the point of the int?

狂风中的少年 提交于 2019-12-10 23:43:28
问题 Starting from FW 4.0, the IntPtr structure has the Add method: public static IntPtr Add( IntPtr pointer, int offset ) Which is great, as it's supposed to address all those questions on IntPtr math we have had (1, 2, probably more). But why is the offset int ? Must it not be IntPtr ? I can easily imagine offsetting a 64-bit pointer by a value which is beyond the int range. For instance, consider Marshal.OffsetOf: public static IntPtr OffsetOf( Type t, string fieldName ) It returns an IntPtr as

ASP + EF loading assembly problem

有些话、适合烂在心里 提交于 2019-12-10 23:35:57
问题 I have a big problem. When I'm running asp SOMETIMES the application is craching with the following error message: Schema specified is not valid. Errors: The types in the assembly 'Data.EF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' cannot be loaded because the assembly contains the EdmSchemaAttribute, and the closure of types is being loaded by name. Loading by both name and attribute is not allowed. Stack Trace: [MetadataException: Schema specified is not valid. Errors: The

Why do I get an Invalid Operation Exception (non STA thread?) running this MSpec test on TeamCity?

↘锁芯ラ 提交于 2019-12-10 22:55:28
问题 As part of the migration of my app to .NET 4, I'm struggling to get some of the WPF unit tests working again with TeamCity. On all the tests that are somehow using a WPF control (a ListItem for example), I get an exception I didn't get before: System.InvalidOperationException: The calling thread must be STA, because many UI components require this. I understand what it means, and after checking, it turns out that my thread is indeed MTA, not STA. My problem is that I have no idea on how to

How to migrate from Google+ Login to Google Sign In in c# MVC

徘徊边缘 提交于 2019-12-10 22:22:15
问题 My web site allows users to register and log in with their Google Account. My c# MVC app uses the feature the template offered using Microsoft.AspNet.Identity.Owin. I have received an email from Google that they are shutting down Google+. The email said to transfer over to Google Sign In. Any good articles that explain this topic for c# MVC apps using Owin features? Any pointers where to start would be greatly appreciated. thanks, Michael 回答1: Just update the package Microsoft.Owin.Security

Nullable “scalar navigation properties” in EF 4.0: Mapping a non-nullable column from a separate database table to a nullable scalar entity property?

核能气质少年 提交于 2019-12-10 22:06:27
问题 Using Entity Framework version 4.0 (or any other version that is compatible with .NET 4.0), I want to map this existing relational database schema: to this logical object model: which I have tried setting up as follows: (I hope the German captions won't be too disorienting.) Entity Framework gives me this error: Error 3031: Problem in mapping fragments …: Non-nullable column FooBs.B in table FooBs is mapped to a nullable entity property. In the logical model, B ought to be nullable. However,