.net-4.0

.NET Framework 4.0 and drawing on Aero Glass issue

别等时光非礼了梦想. 提交于 2019-12-04 08:47:03
In my application I have a form which I tweak by using the DWM API's method DwmExtendFrameIntoClientArea to extend the height of the Aero Glass Title Bar so that part of my form client area is drawn on the Aero frame. To achieve this effect, I also draw a black rectangle on the part of the client area which is 'over' the glass frame so that it appears transparent, as many online articles suggest. This worked pretty well under Windows Vista/Windows 7 but as I downloaded VS 2010 and used the .NET Framework 4.0 as my trarget framework to build my application, this approach no longer works. The

A potentially dangerous Request.Path value was detected from the client (?) with valid URL

断了今生、忘了曾经 提交于 2019-12-04 08:44:31
I have an ASP.NET MVC 4 Web Application running on IIS 7.5 for a few weeks now and I noticed that just recently I have been getting quite a lot of the following errors: System.Web.HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (?). at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context) I know that this exception is caused when the URL path contains illegal characters but the strange thing is that in my case the URL is valid. Here is one example of the

What important difference exists between Monitor.TryEnter(object) And Monitor.TryEnter(object, ref bool)?

怎甘沉沦 提交于 2019-12-04 08:19:17
问题 It seems that these code snippets ought to behave identically: 1: Monitor.TryEnter(object) if (Monitor.TryEnter(lockObject)) { try { DoSomething(); } finally { Monitor.Exit(lockObject); } } 2: Monitor.TryEnter(object, ref bool) - introduced in .NET 4.0 bool lockAcquired; try { Monitor.TryEnter(lockObject, ref lockAcquired); if (lockAcquired) { DoSomething(); } } finally { if (lockAcquired) { Monitor.Exit(lockObject); } } I see from the MSDN documentation on the overload taking a ref bool

What is difference between MemoryCache vs ObjectCache in .net 4.0?

自作多情 提交于 2019-12-04 08:02:18
问题 What is difference between .NET framework 4.0 MemoryCache vs ObjectCache ? Where to use which object? 回答1: ObjectCache is the abstract class that demonstrates how you should build a Cache that adheres to the rules the person who wrote ObjectCache wants you to obey. You cannot instantiate ObjectCache directly as it is abstract. MemoryCache is an actual implementation of ObjectCache. From the documentation: ObjectCache Represents an object cache and provides the base methods and properties for

Is it possible to retrieve data from Active Directory by impersonating a Windows authenticated user in ASP.NET?

佐手、 提交于 2019-12-04 07:57:46
I've been trying to solve this problem all day, and I've read some conflicting information within the standard google message board answers. What I'm trying to do is retrieve a domain user's (that is, the currently logged in user's) email address from active directory. My ASP.NET 4 website is setup for Windows Authentication and everything works fine until the active directory calls. When I do the following, I get a COMException on the search.findAll() line. The exception message is "An operations error occured" (Very helpful message eh?) (Stripped down code for readability) WindowsIdentity

Can .NET 4.0 code interoperate with .NET 2.0 code?

China☆狼群 提交于 2019-12-04 07:57:15
问题 Are there compatibility barriers with a .NET 4.0 assembly calling code in a .NET 2.0 assembly? And vice versa? More specifically, I'm investigating an upgrade to Visual Studio 2010 when using a third party application based on .NET 2.0. The application is extensible by hooks that reference my custom code. And vice versa, my code will reference the application's assemblies. 回答1: The CLR, in .NET 4, can consume .NET 2 assemblies and use them properly. If you want your .NET 2 application to be

Abstract class cannot be sealed in c#?

橙三吉。 提交于 2019-12-04 07:42:55
I read somewhere "Abstract and Sealed modifiers are equivalent to a class which is static" I also found that "When you declare a static class, internally the compiler marks the class abstract and sealed, and creates a private constructor in the IL code" so, I decided to do this: static class A { public static void test() { Console.WriteLine("test"); } } Now, the class "A" cannot be inherited nor instantiated. So, let us write a class B using abstract to prevent instantiation and using sealed to prevent inheritance. But, this approach fails. which should be equivalent to public abstract sealed

WPF 4 multi-touch drag and drop

最后都变了- 提交于 2019-12-04 07:26:11
I have a WPF 4 application where I have implemented Drag and Drop using the standard DragDrop.DoDragDrop approach, but Im doing it using touch instead of Mouse events. My XAML for my Grid (that Im dragging) is as follows: <Grid x:Name="LayoutRoot" ManipulationStarting="ManipulationStarting" ManipulationDelta="ManipulationDelta" ManipulationCompleted="ManipulationCompleted" IsManipulationEnabled="True"> <!-- children in here --> </Grid> Now the code behind is like this: private void ManipulationStarting(object sender, ManipulationStartingEventArgs e) { e.ManipulationContainer = this; e.Handled

nunit on release build: “Common Language Runtime detected an invalid program.”

柔情痞子 提交于 2019-12-04 07:23:46
I upgraded our software from vs2008/.net 3.5 to vs2010/.net 4.0. All third party libraries (most relevant: nhibernate 2.1.2 or 3.0.0, nunit 2.5.2) are still compiled using vs2008. When I run the unit tests for the debug build of our software, everything works fine. On the release build, nunit reports exceptions on 33 of 228 tests: System.InvalidProgramException : Common Language Runtime detected an invalid program. It always happens on the same tests, for both nunit-console and the Resharper 5.0 test runner. When I run them using the Resharper "debug unit-tests" command, all tests pass. It

is it ok to use plinq ForAll for a bulk insert into database?

偶尔善良 提交于 2019-12-04 07:15:49
I'm doing like this: entities.AsParallel().ForAll(o => repository.Insert(o)); is this good, am I going to have more performance with this ? No. This one can be faster, as it leverages the paralellism to the SQL, but in the end the SQL has to make a lock for the table (page), as it makes an insert. therefore each paralell request is executed after another again. If you want to make a bulk insert, than make a SP accepting all entries (e.g. a table with SQL 2008.) or do it with Linq2SQL. that would be the correct design solution. Probably not. Each insert would actually take place on a seperate