.net

How do you localize a database driven website

I've been playing with the .NET built in localization features and they seem to all rely on putting data in resx files. But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in .NET way, or do you create a translations table in SQL and do it all manually? And if you have...

ListBox with Grid as ItemsPanelTemplate produces weird binding errors

I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid. I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions. So far it's all working as I expect. I've got some custom IValueConverter implementations fo...

How to check if there is any read/write activity for a specific harddrive with C#?

I'm curious how to assess if there is any read- or write-activity for a specific harddrive at a given moment with .NET / C#. Second it would be interesting to assess the actual speed of access. Any ideas? ...

No output to console from a WPF application?

I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here? I can reproduce it by creating a WPF application in VS 2008, and simply adding Console.WriteLine("text") anywhere ...

Combine multiple LINQ expressions from an array

I'm trying to combine a list of functions like so. I have this: Func<int, bool>[] criteria = new Func<int, bool>[3]; criteria[0] = i => i % 2 == 0; criteria[1] = i => i % 3 == 0; criteria[2] = i => i % 5 == 0; And I want this: Func<int, bool>[] predicates = new Func<int, bool>[3]; predicates[0] = i => i % 2 == 0; predicates[1] = i =...

Using ASP.NET Dynamic Data site on Windows XP IIS?

I have a Dynamic Data website built in Visual Studio 2008 using .NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine: Server Error in '/FlixManagerWeb' Application. -------------------------------------------------------------------------------- The resource c...

.NET time sinkholes?

What .NET issue have you run into that wasted hours and hours of your time, was nearly impossible to debug, and could have been easily avoided if you had known just one quirk of the framework? ...

Giving character to your unit tests

I have been thinking a lot about unit testing and how to improve the readability of the unit tests. I thought why not give a character to the classes in the unit test to clarify what they do. Here is a simple unit test that I wrote: [TestFixture] public class when_dave_transfers_money_from_wamu_account_to_the_woodforest_account ...

How do you put { and } in a format string

I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this: using System; public class ClassName { public double TheFunction(double input) { // user entered code here } } Ideally, I thi...

.NET WTF?s

There's a ton of classes in the .NET framework. As much as I'd like to think all the engineers behind .NET are brilliant, sometimes, you'll learn how they've implemented something, and you think to yourself, WTF? What are some of the things that have made you pause and ask yourself, "WTF?," while using the .NET library? Here's an examp...

Define a .NET extension method with solution scope

I have a few 'helper' style extension methods I use quite regularly now (they are mostly quite simple, intuitive, and work for good not evil, so please don't have this descend into a discussion around whether or not I should use them). They are largely extending core .NET CLR classes. Currently, I have to copy the 'ExtensionMethods.cs' ...

How do I pass data between activities in Windows Workflow?

I'm not completely sure I understand the workflow way of doing things, but if it's a pipeline n filter style model I should be able to pass data (even strings) from one activity to another. Does anyone know how to do this? Bonus points for a video! I hope this is possible. If WF were the same as my idea of it then it would be extremel...

.NET multiplication optimization

Does the compiler optimize out any multiplications by 1? That is, consider: int a = 1; int b = 5 * a; Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as: const int a = 1; ...

In .NET is there a way to enable Assembly.Load tracing?

In .NET is there a way to enable Assembly.Load tracing? I know while running under the debugger it gives you a nice message like "Loaded 'assembly X'" but I want to get a log of the assembly loads of my running application outside the debugger, preferably intermingled with my Debug/Trace log messages. I'm tracing out various things in ...

How do I determine the file and line # of a C# method from a symbols (.pdb) file?

pdb files contain symbol information for .NET assemblies. I'd like to read a pdb file in order to correlate methods with their file location. The data is contained within it but I can't seem to find a good description of how to get it out. I know about mdbg, but that is very heavy (I think/hope) for what I want. ...

Compiled, strongly-typed alternative to .NET?

Is there a programming language suitable for building web applications, that is compiled, strongly-typed, and isn't ASP.NET? I thought of using Mono (http://www.mono-project.com/), but I wonder if there are any other alternatives. (If the language and framework are open-source, that's a big plus!) ...

Pitfalls for converting a .net 2.0 solution to .net 3.5

We're moving a solution with 20+ projects from .net 2.0 to 3.5 and at the same time moving from Visual Studio 2005 to 2008. We're also at the same time switching from MS Entlib 2.0 to 4.0. Is there any reasons not to let the Visual Studio wizard convert the solution for us? Is 3.5 fully backwards compatible with 2.0? Is Entlib 4.0 ful...

Page.Tostring() behaves a bit weird in .net 1.1?

Hi, I have a control where I have to check in which page I am, so I can set a certain variable accordingly. string pageName = this.Page.ToString(); switch (pageName) { case "ASP.foo_bar_aspx": doSomething(); break; default: doSomethingElse(); break; } this works fine locally and on some developmentservers, however when I put it live,...

Do you think Microsoft will port the .NET Framework to O.S.'s other than Windows?

I mean Microsoft by his will. ...

Best algorithm for synchronizing two IList in C# 2.0

Imagine the following type: public struct Account { public int Id; public double Amount; } What is the best algorithm to synchronize two IList<Account> in C# 2.0 ? (No linq) ? The first list (L1) is the reference list, the second (L2) is the one to synchronize according to the first: All accounts in L2 that are no longer pr...