.net

How to find path of active app.config file?

I'm trying to finish this exception handler: if (ConfigurationManager.ConnectionStrings["ConnectionString"]==null) { string pathOfActiveConfigFile = ...? throw new ConfigurationErrorsException( "You either forgot to set the connection string, or " + "you're using a unit test framework that looks for "+ "the...

Should we not use the System.Web.Caching.Cache class in a WinForms app?

I've seen several articles/blog posts that advocate the use of the System.Web.Caching.Cache in applications that are not for the Web, however, the MSDN documentation quite clearly states that The Cache class is not intended for use outside of ASP.NET applications. It was designed and tested for use in ASP.NET to provide caching for ...

.NET guidelines: Why exception for two-letter acronyms?

Microsofts Framework Design Guidelines define, among other things, the following: "Do capitalize both characters of two-character acronyms, except the first first word of a camel-cased identifier" So there is an exception defined for acronyms that comprise of only two letters, since acronyms with three or more letters are "proper...

C# Call Graph Generation Tool

I just got a heaping pile of (mostly undocumented) C# code and I'd like to visualize it's structure before I dive in and start refactoring. I've done this in the past (in other languages) with tools that generate call graphs. Can you recommend a good tool for facilitating the discovery of structure in C#? UPDATE In addition to the too...

Load view from bin folder?

In an attempt to have several sites with one central set of views I created an external library with my views. They are marked as content and copy always. This views library is referenced in my websites and thus with compiling get a "Views" folder in their bin folder. Then I made a quick custom ViewEngine like this: public class CommonV...

Update Listbox

I have bound a ListBox to a SQL CE database with this code: ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DatabaseWindow}}, Path=Database.Photos1}" This ListBox is populated properly. But when I try to insert a row into the database (InsertOnSubmit + SubmitChagnes), the ListBox is not up...

WPF ListView Inactive Selection Color and element font color

Hello, I'm able to set ListView Inactive Selection Color I used solution described in following question http://stackoverflow.com/questions/382006/wpf-listview-inactive-selection-color I need to change font color of selected inactive element, is there easy way to accomplish this? Thank You ...

Programmatically remove or hide comments/track changes in Word 2007?

I was wondering if this is possible? and if so how? Thanks. ...

SQL/.NET TableAdapters - How do I strongly-type calculated columns in either the database or the DataSet?

We use calculated columns in a few SQL Server 2005 tables which always return data of a specific type (bit, varchar(50), etc...). These tables are consumed by a .NET data layer using strongly-typed datasets and tableadapters, however since the calculated columns are not constrained to a specific type (we always return a specific type, b...

Dynamically identify/locate HTML tables within a page?

Admin users can add HTML content to a website via a CMS textbox control. When this content is displayed to a website visitor, I'd like to identify the presence of a HTML table (added by a Admin user using the CMS) and display an option for visitors to export that table. I can handle the exporting, but identifying the HTML tables has me...

Deep copy System.Windows.Forms.WebBrowser Object/Restore State

Essentially what I want to do is copy a WebBrowser object such that I can do the equivalent of "Open In New Tab" or "Open In New Window" actions, maintaining any posted data. I don't just want to navigate to the same URL as in the original WebBrowser object, rather I want to repeat the HttpWebRequest. Is this possible? How? ...

How to flush HttpListener response stream?

HttpListener gives you response stream, but calling flush means nothing (and from sources it's clear, because it's actually doing nothing). Digging inside HTTP API shows that this is a limitation of HttpListener itself. Anyone knows exactly how to flush response stream of HttpListener (may be with reflection or additional P/Invokes)? U...

How do I snoop on another processes memory from .Net?

I'd like to attach to another process from a .Net console app and explore the data area. Specifically I would like to attach to the 'Spider Solitaire' app in Windows Vista as I am interested in seeing if the cards it deals out are solveable in all situations. Is this possible and if so which APIs should I be looking at? This is a 'just...

How do I use TransactionScope in C#?

I am trying to use TransactionScope, but keep getting the exception below. The app is running on a different machine than the database, if that matters. I am using Sql Server 2005. "Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDT...

Regex with unusual characters

I'm trying to come up with some regex to handle the # sign. Example, #PRODUCT_143# If the input were #PRODUCT_143, the regex #PRODUCT_(\d*$) matches and returns 143 as the match. But adding the # to the end of both the input and the regex causes it to break. what do I need to do here to get this to match? ...

Experience using gcServer="true" to set garbage collector for .NET

Someone has used a configuration enabling the garbage collector optimized for multi-processor machines using Aspnet.config with : gcServer enabled="true" gcConcurrent enabled="true" There was improvement in the performance of your site? It was noticed a problem? ...

Windows Forms - ErrorProvider + DataGridView

How can I hook in the ErrorProvider with individual cells on the DataGridView control? ...

How to refactor tightly coupled classes?

I'm trying to refactor a big tightly coupled application and trying to make it more maintainable and flexible. I've got many unit tests, so I'm hoping to refactor step by step. Which Design & Refactoring Patterns should I consider implementing / applying to accomplish this task ? I can think of some : Extract Interface Extract Meth...

How to create ASP.NET user/server control that uses a list of asp:ListItem as child controls?

I am looking to create a user/server control that will be created with something like the following: <my:MyListControl runat="server"> <asp:ListItem Text="Test1" Value="Test1" /> <asp:ListItem Text="Test2" Value="Test2" /> </my:MyListControl> I am just looking for a start here: Articles or code samples. What base class should I...

How do I implement a custom Brush in WPF?

Where can I find out enough info about how Brushes work to implement my own System.Windows.Media.Brush? I can handle all of the freezable baggage, but it's not really obvious what I need to override to get it to work. Yeah, so I didn't mean that I want to use a predefined brush. I want to extend System.Windows.Media.Brush, which is ...