.net

Get ListBox Displayed Height

Is there a way to determine the displayed height of a Windows Forms ListBox? In an application I am developing, I have a form with a ListBox docked in it. I need to automatically resize the form to remove the any extra space at the bottom which the ListBox does not use due to ListBox.IntegralHeight being set to true. Currently I am si...

How do I programmatically select a tab on a .NET CF TabControl?

With the .NET Framework 2.0/3.5 TabControl, I can programmatically select a tab using the SelectedTab property as shown in the code below: //toggles between tabPage1 and tabPage2 private void button1_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab == tabPage1) tabControl1.SelectedTab = tabPage2; else ...

Need IntPtr for a Form (VB.Net)

I need the intPtr for a form. Control.FromHandle(control) gives me the control from a handle, but I need the opposite--get the handle from a control. How do I do this? ...

Web Deployment Project with an replacement .config geting "changed"

I have cruisecontrol.net building a asp.net web deployment project. This is working great until i created multiple deployment "configurations". Basically we have a dev,test,stage, and prod. The stage and prod configurations have a web.config replacement setup to change the plain text connectionstring section to what our production webs...

Case insensitive string compare in LINQ-to-SQL

I've read that it's unwise to use ToUpper and ToLower to perform case-insensitive string comparisons, but I see no alternative when it comes to LINQ-to-SQL. The ignoreCase and CompareOptions arguments of String.Compare are ignored by LINQ-to-SQL (if you're using a case-sensitive database, you get a case-sensitive comparison even if you a...

remove IIS 7 redirects

Hello, I am trying to debug an IIS server that keeps redirecting *.html files to *.aspx... it sends the following html in response to url.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta htt...

Prevent double-click from double firing a command

Given that you have a control that fires a command: <Button Command="New"/> Is there a way to prevent the command from being fired twice if the user double clicks on the command? EDIT: What is significant in this case is that I am using the Commanding model in WPF. It appears that whenever the button is pressed, the command is execu...

.net Access Forms authentication "timeout" value in code

I'm adding a logout expiration alert to my application and would like to access my web.config forms authentication "timeout" value from my code. Any way i could do this? ...

Visual studio debugging shortcut

What key do I use to step into a method in VS2008 debug mode? If I have a method call like this: string s = StepIntoThisMethod(DoNotStepIntoThisOne(i), NotIntoThisEither(j)); If I use F11, I step into the methods in the argument list. I would like to step into StepIntoThisMethod method ...

What is a quick way to force CRLF in C# / .NET?

How would you normalize all new-line sequences in a string to one type? I'm looking to make them all CRLF for the purpose of email (MIME documents). Ideally this would be wrapped in a static method, executing very quickly, and not using regular expressions (since the variances of line breaks, carriage returns, etc. are limited). Perha...

Using ELMAH in a console application

I just started using ELMAH and am a fan. My team supports a large number of web applications and I'm particularly excited that ELMAH lets us save exceptions from each application to the same MS SQL database table. We also support a few console, DLL and desktop applications. Is it possible to use the ELMAH DLL to log exceptions in these...

"Common Sense" or Practical .NET Coding standards

I'm about to undertake updating our coding standards documentation and I am thinking of perhaps writing them at a somewhat higher level than is commonly done. We have a fair amount of developers that come and go, and they are generally of an intermediate skill level. I want to eliminate the low quality "fluff" sections...for example, "...

Socket Server Disconnect and Reconnect Buffer Error?

I'm using the following TCP Sockets Server/Client example: http://www.codeguru.com/Csharp/Csharp/cs_network/sockets/article.php/c8781/ I'm also using the following CryptoStream example: http://www.obviex.com/samples/Encryption.aspx Problem: Both Server and Clients communicate perfectly until I Stop the Server socket, wait a minute or s...

Automatically updating a file with Revision from TFS?

I'm quite new to TFS (actually I only use it because I have some projects on CodePlex and did not want to go through svnbridge), and I'm looking for something equivalent to the $Revision$ parameter in SVN. Essentially on checkout, I want to update a file to contain the newest Revision number, to be displayed as Version number (just like...

How to Make A Dll 'Plugin' System For Playing AI Bots Against Each Other - In .Net

I'm trying to put together a fun 'contest' of sorts. Developers will write a bot that plays some game - maybe BlackJack and the master program will host the game and let the bots play against each other. I've participated in such things before, but never been involved with the 'host' application. And I'm not sure how to go about doin...

Advice for Windows system scripting+programming

I just got a project where I have to do the following on a Windows OS: detect how many drives (C: D: E: ..etc) are connected to current system what the system labels are for each volume how much storage (both used and free) for each of the drives what format each drive is (NTFS/FAT32) how many files are in a given directory in any o...

Run Visual Studio 2008 Macro on Pre Build Event

I have some Visual Studio Macros created in visual studio which run from the macro explorer and/or keyboard shortcuts. I would like to run these automatically on pre/post build events but see no option to do so in the project properties. Can anyone tell me if this is possible and, if so, how? Thank you Jason ...

How do you keep the WPF window sized to content with an Expander after resize

I've got a WPF window with SizeToContent="Height". This window contains an <Expander /> that displays a list of recent activity. What I'd like is when the expander is expanded the window grows in size proportionally. When hidden the window again resizes proportionally. If the window is resized the expander and it's contained list view sh...

Programmatically apply / deactivate breakpoints in visual studio

Hey, Regardless of other options that may achieve the same result (i.e. adding breakpoints by hand) Is is possible to programmatically add a breakpoint into the source code of a visual studio project? such as try { FunctionThatThrowsErrors(obj InscrutableParameters); } catch(Exception ex) { Log.LogTheError(ex); AddBreakPo...

How would you transfer session info between Java/Servlet's and .NET

I have a web app built on Java Servlet technology. I am thinking of switching to a new framework, possibly switching over to a .NET stack with C# and ASP MVC. I don't want to take the current app down while I develop the new one. The goal is to have the old system run and just develop new modules in a new architecture. If I stay with a...