.net

Inner TransactionScope with different IsolationLevel, how can it be achieved?

The current implementation of TransactionScope lacks the ability to change IsolationLevels in nested scopes. MSDN states: When using nested TransactionScope objects, all nested scopes must be configured to use exactly the same isolation level if they want to join the ambient transaction. If a nested TransactionScope object tries to joi...

How to close a blocked socket

A windows service has an open socket that is receiving data (on a separate thread) In response to the service OnShutdown I would like to signal worker thread to shutdown, but it's currently blocked on the Receive. At the moment I'm timing out on the Receive to check if there is a stop request pending. Is there a better approach, rathe...

SharpSvn giving SASL(-1) error when used on a different server

I am trying to use the SharpSvn library on our build server. On the development machine it works fine but when I put on the build server I get the following error: SASL(-1): generic failure: Unable to find a callback: 2 The code I am using is as follows: public IList<Branch> GetBranches() { using (var client = new Sv...

windbg "Free" object type

Monitoring my program's Virtual Bytes usage while it is running showed that by doing some kind operations, the virtual bytes usage goes up by about 1GB in about 5 minutes. The program deals with tcp sockets and high data transfer throughput between them (~800Mbps). Loading a dump file of the program in windbg showed that the reason for ...

mef and windowsAPICodepack

Hi stackoverflow fellas, I've got a problem which at first looks solved but I can't get it to run. I've got one WPF application project in my solution and a WPF class library which is added at runtime via MEF. In this external Dll I use the TaskDialog of the Codepack. Ok I found the manifest dependency thing and added it to my main WP...

.NET Forms Authentication and CurrentContext.User

If I call FormsAuthentication.SignOut(); with a user logged in (with createPersistentCookie set to false on sign in) should I expect HttpContext.Current.User.Identity.IsAuthenticated to be false? It isn't, and Identity.Name still has a value. Is this right? If this is normal behaviour, what do I need to do to remove all trace of...

Configuration Element Collection Section

I would like to set up a custom app configuration element collection section like this ` <logSection name="Testttt"> <properties name ="Pride"> <pathName="TestingLog.txt"/> <deleteRetention="100"/> <deleteZeroRetention="5"/> <wildcard="*.txt"/> </properties> <properties name ="Adhoc"> ...

Looking inside a lambda / expression tree

Given either of the variables below, how can I 'inspect' them to obtain the parameter value passed in? i.e. 12345. System.Func<DateTime> f1 = () => DateTime.Now.AddDays(12345); System.Linq.Expressions.Expression<System.Func<DateTime>> f2 = () => DateTime.Now.AddDays(12345); Edit: The two answers below by Mika...

Should programmers use SSIS, and if so, why?

As a .NET developer, for what reasons should I prefer SSIS packages over writing code? We have a ton of packages in production where I currently work, and they're a nightmare to both "write" (perhaps draw?) and maintain. Each package looks like a bowl of multicolored spaghetti with C# and VB.NET scripts mixed in at the points where the a...

Is this the "one in ten" time to rewrite?

I'm very much against rewriting an application if it can be avoided. I understand the rule that 9 times out of 10, it's better to refactor, but I'm in a situation where it might be the one time in ten, and I'm looking to find that line. The current situation is: I took over the maintenance of a VB6/SQL application. The total lines of...

Getting a Crash Dump for a .NET Application that Uses Native Interop

I have a .NET application that makes calls to a native Win32 DLL using interop services. When I run this program, it will crash somewhere inside the DLL. However, I have been unable to get any stack dump information. When I run in the Visual Studio debugger, the debugger exits when the crash happens. I get the "Blah-blah-app has stop...

How can I mix the Concurrency Runtime with .NET code?

I've been using the Concurrency Runtime in a C++ static library, and recently wanted to use this library in a C++/CLI project, to take advantage of the Windows Form designer and avoid MFC. Unfortunately, the Concurrency Runtime is not compatible with the /clr switch required in C++/CLI. I tried surrounding the included header files that ...

Don't highight selected cell when user clicks in a data grid row.

I have a DataGrid that is setup like this: <DataGrid AutoGenerateColumns="True" GridLinesVisibility="Horizontal" IsReadOnly="True" ItemsSource="{Binding Documents}" SelectionMode="Single" SelectionUnit="FullRow" /> Can somebody point me in the right direction for making the UI look as t...

XAML Security, Injection, In-Place Editing

I'm working on a new WPF application and we've been experimenting with some attached / dependency properties and triggers to do some things in our XAML. The question came up the other day about the ease of editing xaml in an existing executable. Similar to an IL dump / injection, If someone could export xaml, edit it, and re-package it s...

'var' keyword in c#

Possible Duplicates: C# var keyword versus explicitly defined variables Use of var keyword in C# May I know where to use 'var' keyword and the purpose of using that there ? ...

Background consumer thread lifetime management best practices

I have a C# class library which starts up a background consumer thread (lazily) which listens for tasks to complete from a producer/consumer queue. This class library can be used from any type of .NET application and is currently in use under an ASP.NET MVC web site. The consumer thread is blocked most of the time until a request comes i...

How do I assign an event handler in winfowms using a custom ShowDialog?

I have a ShowDialog that takes several parameters. Is there a way to also pass it a delegate to handle an event on the parent form? (As opposed to instantiating the dialog, then adding the event, then calling the default ShowDialog) Simplified sample, if I wanted a change on the dialog to reflect instantly on the opening form: public...

Winforms Minimization Techniques

I am trying to make my application "flip" when the minimize button is pushed. By flipped, it should be kinda like a coin when flipped. It "flips" down into the taskbar. I am wondering how effects like this are accomplished in WinForms using C#. Can this be done or does something like this need to be done using DirectX? ...

.NET TextBox - Handling the Enter Key

What is definitively the best way of performing an action based on the user's input of the Enter key (Keys.Enter) in a .NET TextBox, assuming ownership of the key input that leads to suppression of the Enter key to the TextBox itself (e.Handled = true)? Assume for the purposes of this question that the desired behavior is not to depress...

Cast T parameter in generic method to DateTime

Hello, I have the following (simplified) method: private static string GetStringFromValue<T>(T val) { if (typeof(T) == typeof(DateTime)) { return string.Format("{0}", ((DateTime)val).Year.ToString("0000")); } return string.Empty; } At the cast "(DateTime)val" I get the following error: Cannot cast expressi...