.net

Enumeration extension methods

In vs2008, is it possible to write an extension methods which would apply to any enumeration. I know you can write extension methods against a specific enumeration, but I want to be able to every enumeration using a single extension method. Is this possible? ...

How to populate a WPF grid based on a 2-dimensional array

I have a 2-dimensional array of objects and I basically want to databind each one to a cell in a WPF grid. Currently I have this working but I am doing most of it procedurally. I create the correct number of row and column definitions, then I loop through the cells and create the controls and set up the correct bindings for each one. ...

What is red/green testing?

I believe I already know the answer, but I am not 100% sure, so just a quick question: What does Red/Green Testing actually mean? I understand it as "Write your tests first, so that they all fail (= all red), then write your code and watch how each test turns green, and when all are green, you're fine". I heard this in Scott's MVC Talk...

Code Coverage for C#/.net

I wonder what options there are for .net (or C# specifically) Code Coverage, especially in the Lower Priced segment? NCover Seems to be very popular and looks quite good. Supports statement coverage and branch coverage. $299 for the 64-Bit Version. Older Beta-Versions available for free. Visual Studio (2008 Pro) | (2005 Team System (...

First "programs" in a non-web environment

I'm starting to re-skill myself in Desktop applications. I've been doing Web applications for a few years now. I've got come decent C# books that I am going through, but they are more like language references. What I would like is a list/site/book with practical exercises, preferably graded in terms of difficulty. They don't necessaril...

Does CompositeWPF support multiple windows/shells?

I'm looking at using CompositeWPF (http://www.codeplex.com/CompositeWPF) - aka Prism, to build an application I am working on. The application isn't a traditional LOB application, however it does present data and state information to the user. One thing which I am unsure of is if CompositeWPF supports more than one Window or Shell. I w...

Click Once - All Users

How to I configure click-once to install apps for all users. On another forum I got to 'use MSI' - thanks - but how. Also, the first installing user may not be admin - which may be a problem. And I want all users to trigger an update check. No local storage, it's a WPF client to a WCF service. We're XP, internal. ...

Label Validating Event Not Firing

I wish to use the Validating event on a label in VB.Net (Visual Studio 2005, .Net Runtime 2.0). I have two text boxes side by side. These are for a %/% split allocation, such as 80/20, 50/50, etc. So, I have validation on each box to ensure that their values are >= 0 and <= 100. It is my desire to have the label off to the left of the t...

Custom Sorting Of A Bound DataGridView

I have a DataGridView bound to a DataTable. I have one column that's a pseudo-int -- you know the kind, where most of the time it has integers but sometimes instead there's an N/A. This column is a varchar, but I want to have it sort like an int column, treating the N/A as a -1. The DataGridView provides for this -- if it's not bound to...

Define an Extension Method for IEnumerable<T> which returns IEnumerable<T>?

Hi, How do I define an Extension Method for IEnumerable<T> which returns IEnumerable<T>? The goal is to make the Extension Method available for all IEnumerable and IEnumerable<T> where T can be an anonymous type. Kind regards. ...

What's the most portable way to make a Silverlight & Regular .NET REST client

Hi, I'm trying to get a Server application to expose some status information using WCF. In particular I'm after using WCF services with RESTful "API". I'm hitting somewhat of a wall when it comes to consuming the REST api from a silverlight app/page that I want to have as an additional type of client... So far I've been successful in de...

Input Audio as a Stream in CF 3.5

I googled around and coulnd't really find an answer. How do I open an audio input device (namely a microphone) as a stream (preferably) on a CE/WinMobile device using Compact Framework? I looked at WindowsMobile.DirectX, at various classes that contained Audio in their name and nothing seemed to do the trick. What I want to do is basi...

How to correctly open a FileStream for usage with an XDocument

I want to append some nodes to an xml document using Linq2XML. The file in question is being used by other processes and they should be able to read the file while I update it. So I came up with this solution, which obviously isn't the correct way (The method doc.Save() fails and says that another process is using the file): using (File...

Call C# methods from C++ without using COM

Hi, Is there a way to create C# objects and call methods from unmanaged C++, but without using COM Iterop? I am looking for something like JNI (but for .Net), where you can manually create the VM, create objects, etc. ...

Can I a implement DisposeBase abstract class?

Is there a catch or hidden problem in using a DisposableBase base class instead of recoding the Dispose pattern on every class? Why aren't everyone using such a relevant class? Edits: I naturally only meant classes that implement IDisposable I know it uses up the option for inheritance, but I'm willing to pay the price (at least when...

Compile a version agnostic .DLL in .NET (Using Manifests?)

Hi, SCENARIO: I have two wrappers around Microsoft Office, one for 2003 and one for 2007. Since having two versions of Microsoft Office running side by side is "not officially possible" nor recommended by Microsoft, we have two boxes, one with Office 2003 and the other with Office 2007. We compile the wrappers separately. The DLLs are i...

How to write something to .txt log file from .aspx page (c#)

This code does not seem to compile, I just need to write something to a small log text file (a new row to end of file). <%@ Import Namespace="System.IO" %> void Page_Load( object sender, EventArgs e ){ FileSystem myFileSystem = new FileSystem(); myFileSystem.WriteAllText(logFile, hash, false); ...

Why, when I impersonate within a WCF service, can my service not load System.Transactions when I try to run a LINQ to SQL query?

I have a WCF service, hosted in IIS 7.0 that needs to run database queries. In order to get the right permissions to do this I am impersonating within the service as follows: Code [OperationBehavior(Impersonation = ImpersonationOption.Allowed)] public void MyOperation(int arg) Configuration <behavior name="ReceivingServiceBehavior">...

Where is the constant for "HttpRequest.RequestType" and "WebRequest.Method" values in .NET?

I need to check the RequestType of an HttpRequest in ASP.NET (or WebRequest.Method). I know that I can just use the string values "POST" or "GET" for the request type, but I could have sworn there was a constant somewhere in some class in .NET that contained the values. Out of curiosity I was wondering if anyone knew what class these st...

SOAP Client in C# without access to a WSDL-file

I'm working with a third party to integrate some of our systems with theirs and they provide us with a SOAP interface to make certain requests and changes in their connected systems. The problem for me is that they do not supply a WSDL-file for me to work against. If I had a WSDL-file it would be a simple matter just to run the supplied ...