.net-4.0

WPF Custom Control, DependencyProperty issue

淺唱寂寞╮ 提交于 2019-12-04 20:08:17
Ive got a test code setup with the custom control: /// <summary> /// Interaction logic for UCTest.xaml /// </summary> public partial class UCTest : UserControl { public static readonly DependencyProperty LastNameProperty = DependencyProperty.Register("LastName", typeof(string), typeof(UCTest), new PropertyMetadata("No Name", LastNameChangedCallback, LastNameCoerceCallback), LastNameValidateCallback); private static void LastNameChangedCallback( DependencyObject obj, DependencyPropertyChangedEventArgs e) { Console.WriteLine(e.OldValue + " " + e.NewValue); } private static object

Compiled Expression Trees misunderstanding?

做~自己de王妃 提交于 2019-12-04 19:55:42
问题 I have this expression : Expression<Func<string, bool>> f = s => s.Length < 5; ParameterExpression p = Expression.Parameter (typeof (string), "s"); MemberExpression stringLength = Expression.Property (p, "Length"); ConstantExpression five = Expression.Constant (5); BinaryExpression comparison = Expression.LessThan (stringLength, five); Expression<Func<string, bool>> lambda= Expression.Lambda<Func<string, bool>> (comparison, p); //lets : test Func<string, bool> runnable = lambda.Compile();

Turn asynchronous calls into synchronous

混江龙づ霸主 提交于 2019-12-04 19:51:37
问题 Is there any good practice (pattern) in turning asynchronous calls into synchronous? I have a third party library who's methods are all asynchronos, to get result of almoust any method you must listen to an event, which will bring some context with it. basically it looks like: service.BeginSomething(...); service.OnBeginSomethingCompleted += ; what I need is to execute some code after BeginSomething when it is really complete (thus after OnBeginSomethingCompleted is triggered). It is very

InitializeCulture() on every single page necessary?

佐手、 提交于 2019-12-04 19:40:09
I have a web forms site that needs to be localized. I mean, it is localized, I just need to set the right language according to the domain. Something like: protected override void InitializeCulture() { var i = Request.Url.Host.ToLower(); var domain = i.Substring(i.Length - 2, 2); if (domain == "se") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("sv-SE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE"); } else if (domain == "dk") { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("da-DK"); Thread.CurrentThread.CurrentUICulture

Why does AcquireToken with ClientCredential fail with invalid_client (ACS50012)?

泄露秘密 提交于 2019-12-04 19:34:51
问题 Why won't my Azure AD application allow an oauth client_credentials grant? I want to use the Azure Graph API, but first I need an oauth token. To get the token, I am trying to use Microsoft.IdentityModel.Clients.ActiveDirectory aka ADAL version 1.0.3 (from NuGet). I'm using the overload of AuthenticationContext.AcquireToken that takes a ClientCredential object. (I can't use the overload that prompts the user to login because I'm writing a service, not an app.) I configured my Azure AD web

Confirmed features of .NET 4.0? [closed]

血红的双手。 提交于 2019-12-04 19:33:48
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center . Closed 8 years ago . Does anyone know what will be in .NET 4.0? I found tuples on codeplex : .... // NOTE : this is a TEMPORARY and a very minimalistic implementation of Tuple'2, // as defined in http://devdiv/sites/docs/NetFX4/CLR/Specs/Base Class Libraries/Tuple Spec.docx /

C# - .NET 4.0 - That Assembly does not allow partially trusted callers

两盒软妹~` 提交于 2019-12-04 19:27:25
When running from a network share, my application throws the following exception: That assembly does not allow partially trusted callers. My application references two DLL files: BitFactory.Logging.dll FileHelpers.dll I'm not sure which one it is having problems with. AllowPartiallyTrustedCallersAttribute : Read up on it, but I do not have the source for either of the DLL files, so I'm not able to add the attribute to those DLL files. CASPOL.EXE : added my network share using a few variations, such as caspol -machine -addgroup 1. -url \\netserver\netshare\* LocalIntranet nothing seems to

Sign data using smart card's private key with ASP.NET, Windows Authentication, and Impersonation

风格不统一 提交于 2019-12-04 19:19:32
I want to know if it is possible to sign data using a smart card's private key without resorting to a java applet or activex control. I am tantalizingly close! Our environment is: AD Domain PKI infrastructure/smart cards (PIV) I knocked up a simple ASP.NET (.net 4.0) web forms app with: Windows Authentication on, Anonymous off Identity Impersonate on With the smart card in the reader I can easily enumerate the certificates on the logged-in user's smart card (StoreLocation.CurrentUser). However, when I try to access the private key (via a CSP), I get an "Access Denied" error. On my local

When is a Generic HttpHandler (an ashx, the IHttpHandler interface) reusable?

╄→гoц情女王★ 提交于 2019-12-04 19:06:01
问题 I've been using Ashx along with jQuery . I've read msdn , I'm talking about the IHttpHandler.IsReusable Property. Gets a value indicating whether another request can use the IHttpHandler instance. What do they mean " the IHttpHandler instance. "? Are they trying to make it alike static for everyone to see and use ? Is it reusable by the same what ? ( QueryString, cookies, etc?) If I write this: public class MyHttpHandler : IHttpHandler { public void ProcessRequest(HttpContext context) {

Entity Framework Code First : How to map flat table to class with nested objects

时光毁灭记忆、已成空白 提交于 2019-12-04 19:00:41
问题 I have the scenario where the data from a single table must be in 2 objects. [Table] -Field1 -Field2 -Field3 -Field4 And the class look like this: [Class1] -Field1 -Field2 -Class2 object here [Class2] -Field3 -Field4 I have set in the Class1 the attribute [NotMapped] over the property of the Class2 which contain the field 3 and 4. I also have added the configuration in the Database Context: public class ConfigurationClass1 : EntityTypeConfiguration<Class1> { public ConfigurationClass1 () {