.net

Bidirectional 1 to 1 Dictionary in C#

I am looking for a generic, bidirectional 1 to 1 Dictionary class in C# (2), ie. a BiDictionaryOneToOne<T, S> which is guaranteed to only contain one of each value and key (up to RefEquals anyway), and which can be searched using either key or value. Anyone know of one, or should I just implement it myself? I can't believe that I'm the f...

Using SMO to copy a database and data

I am trying to make a copy of a database to a new database on the same server. The server is my local computer running SQL 2008 Express under Windows XP. Doing this should be quite easy using the SMO.Transfer class and it almost works! My code is as follows (somewhat simplified): Server server = new Server("server"); Database sourceDa...

Can I use Visual Studio Snippets to generate SQL code

Hi I want to use Visual Studio snippets to generate SQL code, for example we have standard naming conventions for foreign keys etc and it would be great if I could just expand a snippet in my SQL script file. However as far as I can tell the only languages that are supported by the Snippet manager are C#, VB J# and XML http://msdn.mi...

How to change a text value tag to a cdata section

I generate a XMLDocument based on a dataset by binding the dataset to the XMLDocument object and then display it to user in vb.net. I have a requirement in which certain tags to contain cdata sections rather than text value. After generating the XMLDocument how to change only certain tag to cdata section and keeping all else as it is? Or...

Is it OK to return a KeyValuePair from a .NET function?

I was just working on a function that I needed to return two values, one being a column name and one being the value of that column for that current row. I am returning KeyValuePair(of String,Object). I was wondering if this is a good idea or does it make it hard to read/use? ...

Are there any standards to follow in determining where to place menu items?

In developing Windows forms based application, are there any standards that should be followed when designing your form's main menu system? Most windows applications with menu systems will have your standard File | Edit | View | Tools | Help menus. How do you determine placement of any additional top level menu items? In addition,...

Exception vs Validation

I've just come across a property setter that catches exceptions (all Exceptions; I know that's bad, but it's not relevant here), and only logs them. First of all, I think it should through them again as well; why wait for a crash and a log study when you can know something is wrong right away? However, my main question is, do I validat...

Where does DLLImport look for unmanaged DLLs?

A quick question: When declaring the DLLImport Attribute in .Net, where does the runtime look to resolve that DLL dependency? Would I have to dump the DLL and all of its dependencies in the bin folder? ...

How to calculate the correct height for an auto-expanding textbox in Silverlight?

In my Silverlight app I want a multi-line text box to expand every time the user hits Enter. The difficult part is how to calculate the correct height based on the number of text lines. I have tried the following but the textbox becomes too small: box.Height = box.FontSize*lineCount + box.Padding.Top + box.Padding.Bottom + box.BorderT...

How can I dump an entire assembly to source files using reflector?

Is there a way to dump an entire assemblies source to files using reflector? ...

Visualizing the code involved in an action?

I am trying to figure out how a library works and I would like to be able to visualize which methods and lines of code are executed in response to user input (e.g. a keypress or mouse click). Is there a way to do this in .NET? ...

How to use a custom item template containing Path tag in ComboBox (without causing out of range exception)

I have a combo box with the following DataTemplate: <DataTemplate x:Key="ComboBoxDataTemplate"> <StackPanel> <TextBlock Text="{Binding Path='Name'}"/> <Path Data="{Binding Path='PathGeometry'}" Width="64" Height="64" Stroke="Black" Stretch="Fill" StrokeThickness="1"/> </StackPanel>...

Clients to upload data to central server using WCF, how to verify data was uploaded?

Hi, Less than 10 client computers, each with their own installation have to upload data to a central server. The client database looks like: tblSales - rowGuid - randomNumber Central Server database: rowGuid randomNumber dateInserted I plan to use WCF to send the files to the central server. How can I verify the rows were insert...

.net SqlConnection not being closed even when within a using { }

Please help! Background info I have a WPF application which accesses a SQL Server 2005 database. The database is running locally on the machine the application is running on. Everywhere I use the Linq DataContext I use a using { } statement, and pass in a result of a function which returns a SqlConnection object which has been opened ...

About usage of DefaultValueAttribute Class in .Net

So here is the simple code: [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; } I am sure I don't set AnyValue to false again (I just created it). This property is a property of a Page class of ASP.NET. And I am cheking the value in a button event handling function. But somehow it is still false. I w...

Is there a way to use inline comments to document members in .NET?

Is there a way to document a member inline in .Net? Let me explain. Most tools that extract documentation from comments support some kind of inline documentation where you can add a brief after the member declaration. Something like: public static string MyField; /// <summary>Information about MyField.</summary> Is there a way to do t...

How can I change the location of an .InstallState file in a Visual Studio generated MSI

I have an MSI file that I have created using a Visual Studio Setup Project. The installed generates an .InstallState file in the application directory. Is there a way to have this file generated in a different location rather than the default location? ...

Lots of build warnings when COM objects ActiveDs or MSXML2 are referenced

After moving a project from .NET 1.1 to .NET 2.0, MsBuild emits lots of warnings for some COM objects. Sample code for test (actual code doesn't matter, just used to create the warnings): using System; using System.DirectoryServices; using ActiveDs; namespace Test { public class Class1 { public static void Main(string[]...

.NET Runtime 2.0 Error in a service

We have a custom service that writes to a DB (SQL 2005). This is a full 64-bit environment (DB, .NET service). On one of our servers we crash every morning when we have a spike in our volume of data. On another server we run fine. The only differences that I've been able to notice between the two machines is that the one experiencing...

Why doesn't an installed font show up in the font picker dialog?

I've installed an OpenType font on my development machine expecting to then be able to choose that font for a label on a form. The font is available in MS Word so I'm reasonably confident it was installed ok, but I can't see the font in the font-picker dialog for the label in Visual Studio. I also checked the font settings in Tools > O...