.net

Sort XML with C# Before Write

I have an xml document that I am creating using the loop below and the XML writer from C#. It currently works fine, but I wanted to implement a solution where every time the XML is written it automatically sorts it ascending using the driveStart field. I know people say you should do this in XSLT but I am having a hard time finding a g...

Restoring a Differential Backup with an SMO Restore object

I am trying to restore a database by first restoring a full backup and then restoring a differential backup by using the Microsoft.SqlServer.Management.Smo.Restore class. The full backup is restored with the following code: Restore myFullRestore = new Restore(); myFullRestore.Database = "DatabaseName"; myFullRestore.Action = RestoreActi...

Is there anything wrong with using var to declare collections in LINQ queries?

When using LINQ like this: collection.Select (...); Is it better to say: var result = ... or: IEnumerable<Point3> result = ... I am asking it because it's always IEnumerable, right? Is it better to be more explicit in this case? ...

Unity Newbie Question

I'm attempting to use Unity for the first time and I think I might have bitten off more than I can chew. We have a n-tier application that has a base library with several abstract types and then several business scenario specific libraries on top of it w/ concrete types. For ex: The abstract type lead has two implementations, one in a Ne...

SQL Scripts from dotnet with transactions

I have been trying to execute sql scripts from dotnet (C#) but the sql scripts could contain GO statements and I would like to be able to wrap the collection of scripts in a transaction. I found this question and the accepted answer got me going for handling the GO statements, but if I use a BeginTransaction it throws a InvalidOperation...

ProcessExit vs DomainUnload

I'm working on a bug where code is not always being executed before an application shuts down. The code was in a handler for the AppDomain.CurrentDomain.DomainUnload event. I found a post by someone with the same problem who received this advice "By the time the DomainUnload event happens for your default app domain, your code has sto...

What does it mean to filter a collection 'vertically' and 'horizontally'?

In the Essential C# 3.0 book, there is a part where it says: "Projection using the select() method is very powerful. We already saw how to filter a collection vertically (reducing the number of items in the collection) using the Where() standard query operator. Now, via the Select() standard query operator, we can also ...

Prevent a readonly textbox from being grayed out in Silverlight

In Silverlight, How do I make a TextBox with IsReadOnly="True" not become grayed out. The gray effect looks horrible with my app and I would like to disable it, or change its appearance/color. ...

Visually indicating sorting in a ListView control

In Windows Explorer in XP and Vista, when you sort by a column when the ListView is in Details mode, the background of the column is highlighted to indicate that the column is being sorted. An arrow for the direction of the sort is also displayed in the column header. What are the best practices to achieving these effects in your own Win...

Unity configure by convention

Is it possible to configure the Unity Dependency Injection framework to resolve by convention. So in other words if I have an ICustomerRepository when it tries to resolve this it will first look to see if there are any registered types and if not will then by convention try and resolve CustomerRepository class. This would save a lot of ...

C# connection string in web.config file

Hi, In my code behind page, how do I access the connection string which is stored in my web.config file? C# .net Visual Studio 2008. Thanks, R. ...

How to get Emacs fill-paragraph to work on inline XML code doc in my C# modules?

This question is similar to Getting Emacs fill-paragraph to play nice with javadoc-like comments, but for C#. I have comments like this: /// <summary> /// Of these Colonies, and ought to fall themselves by sending a /// constant state of THE unanimous /// Declaration OF Nature and donations are legally 1.E.1. /// </summary> /// /// <...

Inheritance Question

I have a base class, "B", which has two constructors, one with no paremeters and the other that accepts one param, an integer I have a subclass, "S", which inherits from "B" and does not define any constructors in it. I create an instance of S, attempting to pass to the constructor an integer. I get the error: Error 1 Too many argume...

.NET Guitar Chord Library

Hi, I'm wondering if there are any .NET libraries (ideally open-source) that deal with guitar chords (e.g. given either a chord or a set of fret/string combinations it can retrieve the corresponding fret/string combination or chord respectively). I'm having some trouble searching because "C#" is a note and there is a concept of "progra...

Invalid ContentPropertyAttribute on property 'Text'

I am having trouble setting my ContentProperty to "Text". The error I am given is: Invalid ContentPropertyAttribute on type 'MyType', property 'Text' not found. The code behind looks like this: [ContentProperty("Text")] public partial class MyType: UserControl { public MyType() { InitializeComponent...

Need Help understanding Interfaces

Hi I am still having trouble understanding what interfaces are good for. I read a few tutorials and I still don't know what they really are for other then "they make your classes keep promises" and "they help with multiple inheritance". Thats about it. I still don't know when I would even use an interface in a real work example or even...

How can i convert IQueryable<string> to a string array?

Hi, if I do this... rowNames = _myDB.RowSet.Where(r => (r.RowId >= minId) && (r.RowId <= maxId)) .Select(r => r.RowName); it returns an IQueryable, how can I put this into: string[] myStringArray? ...

I have added the child controls on repeater control. that child control not firing the event.

i have create the wizard control , in side this i have create the repeater control.this repeater control has three radio buttons.all are created with dynamically.I want to fire a radio button checkedchange event. find the code: **Panel objPanel = (Panel)Wizard1.WizardSteps[Wizard1.ActiveStepIndex].Controls[5]; Repeater r...

wsdl: type * not declared

It seems that the nested element with a custom defined type doesn't work in visual studio 2008. I have the following wsdl file: <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http...

How do you change default stack size for managed executable.net

We have discovered that one of our auto generated assemblies is throwing a StackOverflowException on new(). This class has (bear with me please) 400+ simple properties that are initialised (most by default(string) etc) in a constructor. We notice that its fine on 64 bits but on 32 bits it goes bang! We need to test if it's reasonable ...