.net

Is it possible for SelectNodes on an XmlDocument to return null?

Is it possible for SelectNodes() called on an XmlDocument to return null? My predicament is that I am trying to reach 100% unit test code coverage; ReSharper tells me that I need to guard against a null return from the SelectNodes() method, but I can see no way that an XmlDocument can return null (and therefore, no way to test my guard ...

What's the best way to embed video in a Windows Mobile 6 application?

App needs to run on the .Net Compact Framework v.3.5. Video can be any format, but I do need to be able to know when it's finished playing, so I can start another one. I'm hoping for a method that doesn't involve unmanaged code, if possible. ...

Mail Storage Quota Checker in C#

We have a requirement to build a tool for users in an Intranet scenario. The tool should check how much percentage of the Mailbox Quota (set in Active Directory) is being used. Currently, they can check their Folder size using Outlook 2003 but this does not show the Quota Limit set for them or the percentage being used. This blog has a...

How to I merge XML from distinct DomDocuments.

What is the easiest way to merge Xml from two distinct Dom Documents? Is there a way other than using the Canonical DataReader approach and then messing with the outputted DOM. What I basically want is to AppendChild to XmlElements without getting: "The node to be inserted is from a different document context." Here is c# code that I ...

How can I make a ListView's columns auto-resize programmatically?

I've found some examples using the Win32 api or simulating the ^+ button combination (ctrl-+) using SendKeys, but at least with the SendKeys method the listview grabs the cursor and sets it to an hourglass until I hit the start button on my keyboard. What is the cleanest way to do this? ...

How to add a Timeout to Console.ReadLine()?

I have a console app in which I want to give the user x seconds to respond to the prompt. If no input is made after a certain period of time, program logic should continue. We assume a timeout means empty response. What is the most straightforward way of approaching this? ...

How do you create a process-wide singleton object?

I read that the unit of granularity for static fields in .Net are per AppDomain, not per process. Is it possible to create a process-wide singleton object? ...

Anyone using the Entity Framework *Well*?

Has anyone actually shipped an Entity Framework project that does O/R mapping into conceptual classes that are quite different from the tables in the datastore? I mean collapse junction (M:M) tables into other entities to form Conceptual classes that exist in the business domain but are organized as multiple tables in the datastore. All...

NHibernate.MappingException: No persister for:

Now, before you say it I DID google and my hbm.xml file IS an Embedded Resource. Here is the code I am calling: ISession session = GetCurrentSession(); var returnObject = session.Get<T>(Id); Here is my mapping file for the class: <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <cla...

Crash Instantiating System.Xml.Serialization.XmlSerializer in C#.

We're seeing a crash when instantiating an instance of the System.Xml.Serialization.XmlSerializer class in a C# library. The crash occurs in the constructor, when it tries to add a duplicate key to a dictionary. I've included a stack trace below. This crash is only occurring on one machine, and repairing our installation of .NET 3.5 d...

When creating a new GUI, is WPF the preferred choice over Windows Forms?

Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution. But on the other side a lot of things are wo...

Best way to send an email from a .NET application?

I'm working on a Windows Forms (.NET 3.5) application that has a built-in exception handler to catch any (heaven forbid) exceptions that may arrise. I'd like the exception handler to be able to prompt the user to click a "Send Error Report" button, which would then cause the app to send an email to my FogBugz email address. What's the b...

good c# asp.net open source project for code study.

Can anyone recommend a good asp.net c# open-source project for the purpose of studying the code to become a better programmer? ...

What exactly is "managed" code?

I've been writing C / C++ code for almost twenty years, and I know perl, python, php, and some java as well, and I'm teaching myself javascript. But I've never done any .NET, VB, or C# stuff. What exactly does "managed" code mean? Wikipedia describes it simply as "code that executes under the management of a virtual machine", and it spec...

Help Understanding .Net Configuration Options

Hi, I'm really confused by the various configuration options for .Net configuration of dll's, ASP.net websites etc in .Net v2 - especially when considering the impact of a config file at the UI / end-user end of the chain. So, for example, some of the applications I work with use settings which we access with: string blah = AppLib.Pro...

Open a URL from Windows Forms

I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser. What is the best way to open a URL in the user's default browser from a Windows Forms application? ...

Loading different versions of the same assembly

Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process? I need to do some data migration from the old version of the app to the new version. Please let me know if this is possible or should I use 2 separate processes. ...

How did my process exit?

From C# on a Windows box, is there a way to find out how a process was stopped? I've had a look at the Process class, managed to get a nice friendly callback from the Exited event once I set EnableRaisingEvents = true; but I have not managed to find out whether the process was killed or whether it exited naturally? ...

Are CLR stored procedures preferred over TSQL stored procedures in SQL 2005+ ?

My current view is no, prefer Transact SQL stored procedures because they are a lighter weight and (possibly) higher performing option, while CLR procedures allow developers to get up to all sorts of mischief. However recently I have needed to debug some very poorly written TSQL stored procs. As usual I found many of the problems due t...

Can you recommend low cost automated testing tools for a .NET Winforms application?

Looking for an automated testing tool to support functional/regression testing for a .NET Winforms client server commercial application. The top tier products: HP QuickTest Pro, Borland SilkTest, IBM Rational Functional Tester and Compuware TestPartner are in the 5-10K price range. Would you recommend a lower cost tool set for function...