.net

How do I convert a date to a HTTP-formatted date in .Net / C#

How does one convert a .Net DateTime into a valid HTTP-formatted date string? ...

A ThreadStateException occures when trying to restart a thread

From time to time I get a System.Threading.ThreadStateException when attempting to restart a thread. The code in question is as follows: // Make sure the thread is done stopping while (this.mThread.ThreadState == ThreadState.Running) { Thread.Sleep(0); } // Respawn a thread if the current one is stopped or doesn't exist if (this.mThread...

Override tab behavior in WinForms

I have a UserControl that consists of three TextBoxes. On a form I can have one or more or my UserControl. I want to implement my own tab behavior so if the user presses Tab in the second TextBox I should only move to the third TextBox if the the second TextBox has anything entered. If nothing is entered in the second TextBox the next co...

Replacement for for... if array iteration

I love list comprehensions in Python, because they concisely represent a transformation of a list. However, in other languages, I frequently find myself writing something along the lines of: foreach (int x in intArray) if (x > 3) //generic condition on x x++ //do other processing This example is in C#, where I'm under the ...

Programatic access to call stack in .net

How can I get programmatic access to the call stack? ...

.NET 3.5 SP1 and aspnet_client Crystal Reports

I recently (a few days ago) installed .NET 3.5 SP1 and subsequently an aspnet_client folder with a bunch of Crystal Reports support code has been injected into my .net web apps. Anybody else experienced this? Am I correct in saying that this is a side effect of SP1? What is this? ...

C# .NET listing contents of remote files

Is it possible in .NET to list files on a remote location like an URL? Much in the same way the System.IO classes work. All I need is the URLs to images that are on a remote server. ...

quoting System.DirectoryServices.ResultPropertyCollection

I'm missing something here: $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter = ("(objectclass=computer)") $computers = $objSearcher.findall() So the question is why do the two following outputs differ? $computers...

Disabling a ListView in c#, but still showing the current selection

I have a ListView control, and I'm trying to figure out the easiest/best way to disallow changing the selected row(s), without hiding the selected row(s). I know there's a HideSelection property, but that only works when the ListView is still enabled (but not focused). I need the selection to be viewable even when the ListView is disabl...

Preventing Memory Leaks with Attached Behaviours

Hi guys, I've created an "attached behaviour" in my WPF application which lets me handle the Enter keypress and move to the next control. I call it EnterKeyTraversal.IsEnabled, and you can see the code on my blog here. My main concern now is that I may have a memory leak, since I'm handling the PreviewKeyDown event on UIElements and ne...

[ADO.NET] System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

Anybody ever get this error and/or have any idea on it's cause and/or solution? I'm asking this on behalf of a friend but there is info at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=125227&SiteID=1 Update The connection string is "=.\SQLEXPRESS;AttachDbFilename=C:\temp\HelloWorldTest.mdf;Integrated Security=True" I sug...

[ADO.NET] What's the deal with |Pipe-delimited| variables in connection strings?

I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is that hard-coded or is there a generalized mechanism at work along the lines of %environment variables%? ...

How to load plugins in .NET?

I'd like to provide some way of creating dynamically lodable plugins in my software. Typicial way to do this is using the LoadLibrary WinAPI fuction to load a dll and calling GetProcAddress to get an pointer to a function inside that dll. My question is how do I dynamically load a plugin in C#/.Net application? ...

.Net Dynamic Plugin Loading with Authority

What recommendations can you give for a system which must do the following: Load Plugins (and eventually execute them) but have 2 methods of loading these plugins: Load only authorized plugins (developed by the owner of the software) Load all plugins And we need to be reasonably secure that the authorized plugins are the real deal...

64bit .NET Performance tuning

I know that .NET is JIT compiled to the architecture you are running on just before the app runs, but does the JIT compiler optimize for 64bit architecture at all? Is there anything that needs to be done or considered when programming an app that will run on a 64bit system? (i.e. Will using Int64 improve performance and will the JIT com...

Alpha blending colors in .NET Compact Framwork 2.0

In the Full .NET framework you can use the Color.FromArgb() method to create a new color with alpha blending, like this: Color blended = Color.FromArgb(alpha, color); or Color blended = Color.FromArgb(alpha, red, green , blue); However in the Compact Framework (2.0 specifically), neither of those prototypes are valid, you only get:...

Static Methods in an Interface/Abstract Class

First off, I understand the reasons why an interface or abstract class (in the .NET/C# terminology) cannot have abstract static methods. My question is then more focused on the best design solution. What I want is a set of "helper" classes that all have their own static methods such that if I get objects A, B, and C from a third party ...

UrlEncode through a console application?

Hi,normally I would just use: HttpContext.Current.Server.UrlEncode("url"); But since this is a console application, HttpContext.Current is always going to be null. Is there another method that does the same thing that I could use? ...

How best to use File Version and Assembly Version?

In .NET there are two version numbers available when building a project, File Version and Assembly Version. How are you using these numbers? Keeping them the same? Auto-incrementing one, but manually changing the other? Also what about the AssemblyInformationalVersion attribute? I'd found this support Microsoft Knowledge Base (KB) ar...

Why does VS 2005 keep giving me the "'x' is ambiguous in the namespace 'y'" error?

Bounty: I will send $5 via paypal for an answer that fixes this problem for me. I'm not sure what VS setting I've changed or if it's a web.config setting or what, but I keep getting this error in the error list and yet all solutions build fine. Here are some examples: Error 5 'CompilerGlobalScopeAttribute' is ambiguous in the namesp...