.net

Are Try Catches still useful?

When I first started programming in .NET I used try/catches all the time. I am finding lately though I rarely ever use them for web applications. My exception (no pun intentended) is unmanaged code that could potentially create a memory leak such as com objects. Are they really needed anymore or do they just clutter things up? UPDATE: ...

Help with Dependency Injection in .NET

Can someone explain dependency injection with a basic .NET example and provide a few links to .NET resources to extend on the subject? This is not a duplicate of http://stackoverflow.com/questions/130794/what-is-dependency-injection because I am asking about specific .NET examples and resources. ...

How to Implement Custom Windows Forms Designer ?

How can we implement Windows Forms Designer in a WinForms application ? Visual Studio uses System.ComponentModel.Design namespace to implement the Form Designer. How can we use this to implement a Form Designer in a WinForms application ? Is there any other library available for achieving the same ? ...

SQLDataReader dispose?

I'm working with legacy code here and there are many instances of SQLDataReader that are never closed or disposed. The connection is closed but, I am not sure if it is necessary to manage the reader manually. Could this cause a slowdown in performance? ...

Why is List<T>.ForEach faster than standard foreach?

Consider this: Requisite: //The alphabet from a-z List<char> letterRange = Enumerable.Range('a', 'z' - 'a' + 1) .Select(i => (Char)i).ToList(); //97 - 122 + 1 = 26 letters/iterations Standard foreach: foreach (var range in letterRange) { Console.Write(range + ","); } Console.Write("\n"); Inbuilt foreach: letterRange.ForEach(r...

5 Textbox, 2 Buttons. How to assign textBox to Button?

I want to give my users the option to use a textbox and press Enter. The challenge is that I have 5 textbox, and 2 options. 3 textbox belong to one button, and 2 textbox to the other. How do I trigger a particular Button according to the textbox the user was in when he press Enter? ...

Help me find the best of WPF

I would like to find what people got the most out of using WPF, in particular: The best and stunning UI examples out there Dark corners that no other UI can implement with ease and style (say MFC or GTK) Professional examples with code Suggestions? Probably the best book on the subject is WPF in Action with Visual Studio 2008 ...

Is there a built-in method to binary search through the entries in the .NET EventLog.Entries collection?

I am developing a log parsing service that captures specific security events in the Windows Event Log. My initial thought was to use Microsoft's LogParser, but I am not looking for any functionality beyond selecting specific Instance/Event IDs already known in advance. After some benchmarking, I found that iterating over the entire .NE...

How to insert single quotes on a databound asp:hyperlink field in asp.net?

I am trying to bind an ASP.NET hyperlink to the "Handle" column of my dataset like this: <ItemTemplate> <asp:HyperLink ID="idTracking" runat="server" NavigateUrl='<%# "javascript:SendPath(" + Eval( "Handle", "{0}") + ")" %>' Text="Test" /> </ItemTemplate> I would like the NavigateUrl to...

Entity Framework - Using GUID as condition

Hi, How can I use this sample Inheritance and Associations with Entity Framework but using a data type GUID as Condition? In this sample, I only use Strings and Integers as Condition. Thanks ...

How do I display selected value in a cascading drop down list?

I want extension of the following code for selected value in edit view. take a case of country -> state -> city. i have script CascadingDropDownList.js: function bindDropDownList(e, targetDropDownList) { var key = this.value; var allOptions = targetDropDownList.allOptions; var option; var newOption; targetDropDownL...

Reusing asmx webservices in multiple projects

We have multiple projects in our system that want to share the same asmx webservice. Does anybody have any advice / best practices on how to do this. The problem is that the webservices are constantly changing so i can't just add a webreference to production. Also that is dangerous because when doing development I want it pointing t...

Grid Control

I have been tasked to create a control that has hot spots that will allow drag and drop of images. These locations will change based on what is being dragged onto the control. After dropping the image on the control it will need the ability to move to a new location (either by drag and drop or using the arrow keys). The closest example ...

Converting EBCDIC Char to Hex values (AFP EBCDIC data)

I working with some EBCDIC data that I need to parse and find some Hex values. The problem that I'm having is that it appears that I'm reading the file in with the incorrect encoding. I can see that my record begins with "!" (which is a x5A in EBCDIC) but when doing the conversion to hex it returns as a x21, which is the ASCII value for ...

Create new instance or just set internal variables

I've written a helper class that takes a string in the constructor and provides a lot of Get properties to return various aspects of the string. Currently the only way to set the line is through the constructor and once it is set it cannot be changed. Since this class only has one internal variable (the string) I was wondering if I shoul...

Where is Message defined in .Net, using the Compact Framework?

Should be an easy question, so don't all pile on - I'm trying to override WndProc like this: using System; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; snip... public class GTextBox : ...

TripleDES: Specified key is a known weak key for 'TripleDES' and cannot be used.

I'm using the .NET 3.0 class System.Security.Cryptography.MACTripleDES class to generate a MAC value. Unfortunately, I am working with a hardware device that uses "1111111111111111" (as hex) as a single-length DES key. The System.Security.Cryptography library does some sanity checking on the key and returns a Exception if you try to us...

multiple folders in App_Code Folder

I am making multiple sub folders in my App_Code folder to organize my classes and it seems it is working fine, is there any restriction on that? like: App_Code Ui TextBoxes Labels ...

What is the difference between Server side skills and desktop development skills?

This morning, I read a very good question about what the person should expect from a Sharepoint position. I have a similar question about server side engineering. What can I expect from server side engineering positions, and how is it similar and different from desktop development? I have experience with WinForms, WPF, some light mu...

How do I detect if I'm running in the console

Is there a simple way to have a code library automatically detect if it's being called from a console application or a windows application? I'd like my library not to report to the Windows Event log if it's being called from a console window, but instead report to the console window. If however, it's not being run from within a console...