.net

Binding Generic List Array to GridView

Hi I have a List which returns an array of "Question". My question is how can I bind this to a grid view? When I try to call Question.Ordinal I get that it does not exist in the data source. I am using the following code: GridView1.DataSource = myList.GetQ(); GrdiView1.DataBind(); myList.GetQ() returns a List which is an array of "...

Why is my C# method not called?!

Why is my X method below not being called?! static class Program { private static void Main() { X((IEnumerable<int>)null); } public static IEnumerable<T> X<T>(IEnumerable<T> e) { if (e == null) throw new ArgumentNullException(); yield break; } } I tried stepping into the debu...

What do you have in your log4net config? Hacks, optimizations, observations?

This is my log4net config file <?xml version="1.0" encoding="utf-8" ?> <log4net debug="true"> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" > <filter type="log4net.Filter.LevelRangeFilter"> <acceptOnMatch value="true" /> <levelMin value="DEBUG" /> <levelMax value="FATAL" /> </f...

What is the difference between IEnumerator and IEnumerable?

What are the differences between IEnumerator and IEnumerable? ...

Find object data duplicates in List of objects

Using c# 3 and .Net Framework 3.5, I have a Person object public Person { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public int SSN { get; set; } } and I've got a List of them: List<Person> persons = GetPersons(); How can I get all the Person objects in per...

Load test a .NET desktop client

I need to automate load tests on a .NET desktop application using an automated script, preferably one that is able to record mouse clicks and keyboard entries. I will have about 10 desktops at my disposal and I want to simulate up to 10 users on each box (as an alternative to installing 100 boxes). Are there any tools that can be used...

Can I get "WAR file" type deployment with ASP.NET?

Sometimes J2EE-savvy people look at ASP.NET and wonder, where's the support for deploying an app as a single unit? JSP/Servlet apps can be deployed as WAR files, with all pages, content, metadata, and code in that single archive. The war file can be versioned, easily moved around. There's an assurance that the entire app is contained...

.Net - Reflection set object property

Is there a way in .Net c# 3.5 I can use reflection to set a object property ? Ex : MyObject obj = new MyObject(); obj.Name = "MyName"; I want to set obj.Name with reflection. Something like : Reflection.SetProperty(obj, "Name") = "MyName"; Is there a way of doing this ? ...

Why does a WPF Popup close when its background area is clicked?

I have a WPF Popup control that contains some editing controls (list boxes, text boxes, check boxes) laid out with quite a bit of whitespace. Popup.StaysOpen is set to False, which is required. If the user clicks elsewhere in the application, the editing operation should be considered aborted and the popup should close. Unfortunately ...

Free Syntax Highlighting .NET Editor

I need incorporate a syntax highlighting editor control into my application. It is required that the control be free and native .NET code only so the Scintilla.NET control is not feasible. The reason for this is because it is a ClickOnce application. I would like answers that use WinForms or WPF. It doesn't have to be from the same vend...

How to use a single SqlTransaction for multiple SqlConnections in .NET?

I have SQL Server 2000, it doesn't support MultipleActiveResults. I have to do multiple inserts, and it's done with one connection per insertion. I want to begin a transaction before all insertions and finish it after all insertions. How do I do it? ...

What is the preferred method for handling unexpected enum values?

Suppose we have a method that accepts a value of an enumeration. After this method checks that the value is valid, it switches over the possible values. So the question is, what is the preferred method of handling unexpected values after the value range has been validated? For example: enum Mood { Happy, Sad } public void PrintMood(Mo...

Setting SqlDateTime.Null in a constructor

How do I set a null value for an optional DateTime parameter in a constructor? I'm using the following constructor below and I want the optional parameter admissionDate to be a null DateTime. Setting it to Nothing actually gives it a value (something like #12:00:00 #). Public Sub New(ByVal obj1 as Object, Optional ByVal admissionDate ...

Problem with mapping in NHibernate

I've the following class: public class Customer { public virtual int CustomerID { get; protected set; } public virtual string AccountNumber { get; protected set; } public virtual string CustomerType { get; set; } public virtual int TerritoryID { get; set; } public virtual SalesTerritory Territory { get; protected set...

Custom behavior if silverlight does not exist

using the Silverlight control (asp:Silverlight) on an aspx page, is there a way to customize the behavior if silverlight does not exist? I want to display a table with images in them if silverlight does not exist on the client. ...

How to modify .rules files without compileing entire workflow assembly?

I have a situation where I need to update/edit/delete rules in .rules file. without re-compileing my workflow assembly. I tried to make .rules file as a 'Content' of my workflow project instead of 'Embedded Resource'. However, the compliler is giving me the compile time error stating that the RuleSet is not defined. Activity 'policyAct...

Detecting USB drive insertion and removal using windows service and c#

Looking into possibility of making an USB distributed application that will autostart on insertion of an USB stick and shutdown when removing the stick Will use .Net and C#. Looking for suggestion how to approach this using C#? Update: Two possible solutions implementing this as a service. - override WndProc or - using WMI query with ...

How is the machineKey validationKey used when creating a sha1 hash?

<machineKey validation="SHA1" validationKey="<64-byte key>" What exactly does the validationKey do? Say I create a hash with SHA1. How does the validationKey play in to it? Consider this code: HMACSHA1 hashSha = new HMACSHA1(_validationKey); byte[] ret = hashSha.ComputeHash(bytes, offSet, count); return ret; We are generating a new...

Is there a way to tell what DLL a given .net assembly is in?

Long story short: We've got a system that we're moving from one server to another. At this point, the only issue is that there's an assembly missing on the new box. On the old box, we can see the assembly name, but for the life of us we can't figure out which dll the code is physically in so we can move it to the new box. Is there som...

What's the best way to test WCF services?

I've used this tool that microsoft ships with visual studio because it's quick and dirty http://msdn.microsoft.com/en-us/library/bb552364.aspx But it's kinda clunky and hard to work with. Are there any other useful test clients out there that you use and don't require creating a new visual studio project and compiling code? EDIT: I'm...