.net

What do you test with your unit tests?

TDD is something that seems to be on everybody's lips these days, and I have tried some on my own but I don't think I'm getting the idea. I am getting a grip on how to write a unit test, but I don't understand exactly what my unit tests should test. If I have an action method that returns a list of data, what should I verify? Only that...

Find recent backup using SMO

Does anyone know how to find the most recent backup for a database using SMO? ...

"too many automatic redirections were attempted" error message when using a httpWebRequest in VB.NET

I am attempting to request a page like "http://www.google.com/?q=random" using the webrequest class in vb.net. we are behind a firewall, so we have to authenticate our requests. I have gotten past the authentication part by adding my credentials. But once that works it seems to go into a redirecting loop. Does anyone have an ideas, comm...

Control.ResolveUrl versus Control.ResolveClientUrl versus VirtualPathUtility.ToAbsolute

Is there any benifit to using one of these methods over the other when resolving paths which start with the tilde (~)? Generally, what is a better practice, should you be sending relative paths or absolute paths down in your html? ...

Can I change an XText object into a string with character references and entities resolved?

Given this XML: <element>Circles &amp; boxes</element> What I would like to do is store the string value of the element as a string, with all of the character references and entities resolved to their equivalent unicode characters. So, for this element, I would want "Circles & Boxes." When I do this (text is an XText object represen...

I get errors when viewing forms in the designer - how can i avoid this?

Some of my forms show errors when i load them in the designer. This is because in their constructors they use system settings loaded from a configuration file. When the form is loaded in the designer it uses some random path and unsurprisingly the config file isn't there. eg. The configuration file C:\Documents and Settings\Rory\Local...

What objects should you return from the data access layer to the business layer an n-tier system

If you have, for example, a database table called Person (ID,Name etc) what kind of object should the data access tier return to the business tier? I'm thinking something like this: //data access tier public class DataAccess{ public interface IPerson{ int ID{ get; set; } string Name{ get; set; } } internal class P...

Is there any simple way to concatenate two BitArray (C# .NET) ?

I have var previous = new BitArray(new bool[]{true}); var current = new BitArray(new bool[]{false}); I want to concatenate them. I have already tried: var next = new BitArray(previous.Count + current.Count); var index = 0; for(;index < previous.Count; index++) next[index] = previous[index]; var j = 0; for(;index < next.Count; index+...

Force a custom WPF Control to resize correctly

I have written a WPF user control and part of it involves dynamically adding elements to a canvas which effects the height of said canvas. The canvas is nested within a grid. When I dynamically add my elements the height of the canvas changes, but the canvas ends up extending beyond the edge of the overall control rather than causing the...

Clipboard.GetText returns null (empty string)

Hi - My clip board is populated with text but when I run string clipboardData = Clipboard.GetText(System.Windows.Forms.TextDataFormat.Text); I get back an empty string. I've toyed with various forms of the call including: string clipboardData = Clipboard.GetText(); string clipboardData = Clipboard.GetText(System.Windows.Forms.Text...

ASP.NET set theme based on URL

I have a web app that up until now has been skinned (just basic colours and logos, nothing complicated) to a single company , however now since the merging with another company the site needs to be branded as two seperate companies (operation is exactly the same for both, and they share the same data). The simplest way would be to just c...

Generating XML serialization assemblies in x86 targetted mode

Usually I have no problem ticking the box that generates serialization assemblies for my .Net code. However, I just changed by platform target to 'x86' instead of 'Any CPU' to fix some problems when running on x64 architecture. Now, I get the error that Trigger.XMLSerialization.dll references Trigger.dll [version=0.0.0.0 culture=neutra...

EPS to JPG Converter

Anyone know of a good library to wrap via c# to convert EPS to JPG Files? ...

Do not overwrite the app.config when deploying with clickonce

How can I specify my app to not overwrite the app.config on the client machines when the app is updated by clickonce? ...

LINQ to SQL - Partial class to selectively change shape

What I have: LINQ to SQL auto generated class, which corresponds to the shape of its SQL table. TABLEA ======== column1 column2 What I want to do: Extend TABLEA class to include a new property, whose related column will be present only when a particular stored procedure is called. The stored procedure return type will be of TABLEA....

Upgrade to 3.5 SP1 & 3.5 Family Update on client systems can break my code?

I have a server hosting a remoting application using .NET 3.5. It has been running fine. In the last couple of days I have had numerous reports of users not being able to access the application after running the "Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86" update. I am tempted to ru...

Changing the template of a TreeViewItem when it is selected

I'm having some problems changing the DataTemplate that is used for a TreeViewItem when it is selected. Ideally, I would like each item to contain a TextBlock, and then when selected it should contain a TextBox instead. Here is what I have so far (I used this question as a starting point): <Window> <Window.Resources> <Hiera...

How should client Flash(SWF) communicate with server-side .NET?

So I have ASP.NET running on the server in IIS7. I think I'm going to use MVC for some static pages and basic dynamic forms - but the majority of the client side is written in Flash/ActionScript. What's the simplest, most succint, most DRY way of building/generating proxies between client and server? Which format should I use? JSON ...

WCF DataContract...

hi I have one datacontract as base object and i have two derived datacontract object. In Operation contract i return only base object. SO since base object is represnted in service and opreational contract the derived class are not visible in client side (or) not publish in web service.? how can i create the derived object in client ...

Trouble casting results of Select() to a List<T>...

What am I missing here? I want to do a simple call to Select() like this: List<int> list = new List<int>(); //fill the list List<int> selections = (List<int>)list.Select(i => i*i); //for example And I keep having trouble casting it. What am I missing? ...