.net

Is there a good .NET library for reading RAW files?

We're writing a .NET-based app to read images including RAW files. Is there a good library we can use? Perhaps a wrapper around dcraw or libraw? License-wise, LGPL is fine but GPL wouldn't be. ...

.NET Dictionary: Potential concurrency problems?

Hi all. I'm working on maintenance of a .NET project, and I'm having some troubles which I'll gladly share with you guys =) The problem code: if( evilDict.Count < 1 ) { foreach (Item item in GetAnotherDict()) if (!evilDict.containsKey(item.name.ToLower().Trim())) evilDict.add(item.name.ToLower().Trim(), item.ID)...

ASP.Net Compilation Conflict... My usercontrol exists in two locations

I get the following error message trying to run my page Compiler Error Message: CS0433: The type 'usercontrols_BirthDetails' exists in both 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5c377e82\1f883022\App_Web_ub0hcxgl.dll' and 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\5c...

How do I get a TabControl to use the full width of its parent?

The standard System.Windows.Forms.TabControl component draws a border around the TabPages it contains. If you set its Dock to Fill, these borders run up to the edge of the parent control, but they're still there, taking up screen space. In Visual Studio, if you dock two windows in the same place, you get a TabControl-like set of tabs a...

How do you change NHibernate's connection string per HTTP request?

As above really. ...

What key to use if adding a data template to the resources of a control

Howdy, I have a data template that is defined in a XAML file. The root of the XAML is not a resource dictionary but the data template itself. Now I want to add this data template to the resources of a control. Unfortunately, I don't know what key to use. myControl.Resources.Add(???, dataTemplate); Although I use the data templates Da...

Convert? Domain objects to DTOs - Cannot create an instance of an interface

Hi I need to pass some objects to and from .Net and a Flex presentation layer. I need to pass and recieve the following object. public class Room: BasicRoom { private int _seatingCap; private RoomType _roomType; private IList<Equipment> _equipment; public virtual RoomType roomType { get { return _roomType; }...

asp.net Menu Control - Formatting

I am attempting to use a .sitemap file to build a menu in my site; however I am having a number of issues with the output. Firstly, the table output wasn't nice - I downloaded the 'CSSFriendly' DLL (http://www.codeplex.com/cssfriendly).. This now gives the output in ul and li's .. But I want the menu to be free of javascript or css th...

Is there a WPF Cheat Sheet available?

I'm looking for a WPF cheat sheet that has the WPF markup extensions for binding, resources, and other common things in WPF.But so far I've had trouble finding it. Anyone know where I could find one? Thanks Edit: Thanks to John and Nir for creating two WPF cheat sheets and posting them here John's XAML for WPF CheatSheet 1.0 (Draft...

"Reliable" file work with .NET

Hi, An application needs a counter, which value to be stored in a text file. Sometimes it happens on very short intervals. This test code rewrites a text file very often (f.e. every 100 milliseconds): int counter = 0; while (true) { WriteToFile(counter); counter++; Thread.Sleep(100); } private void WriteToFile(int counter) { byt...

Why does Boolean.ToString output "True" and not "true"

true.ToString() false.toString(); Output: True False Is there a valid reason for it being "True" and not "true"? It breaks when writing XML as XML's boolean type is lower case, and also isn't compatible with C#'s true/false (not sure about CLS though). Update Here is my very hacky way of getting around it in C# (for use with XML) ...

ReadOnlyCollection or IEnumerable for exposing member collections?

Is there any reason to expose an internal collection as a ReadOnlyCollection rather than an IEnumerable if the calling code only iterates over the collection? class Bar { private ICollection<Foo> foos; // Which one is to be preferred? public IEnumerable<Foo> Foos { ... } public ReadOnlyCollection<Foo> Foos { ... } } /...

Why doesn't .net/C# eliminate tail recursion?

I found this question about which languages optimize tail recursion. What I want to know is why C# doesn't optimize tail recursion, whenever possible? For a concrete case, why isn't this method optimized into a loop (VS2008 32 bit, if that matters)?: private static void Foo(int i) { if (i == 1000000) return; if (i % 100 == 0) ...

C#: Centering controls within a form in .NET (Winforms)?

I'm trying to center a fixed size control within a form. Out of interest, is there a non-idiotic way of doing this? What I really want is something analogous to the text-align css property. At the moment, I'm setting the padding property of the surrounding form to a suitable size and setting the Dock property of the control to fill. ...

DB Connections in ASP.NET, MySQL vs. SQL Server

I'm using MySQL in an ASP.NET project I'm currently working on, I did some tests to test the performance of the MySQL .NET provider but unfortunately I'm not very pleased with the results. A very simple loop that only opens the connection was 10x faster in SQL Server: // MySQL const string CONNECTION_STRING = "server=localhost;databa...

Best way to unbind wpf listview

Hi , I have WPF listview bound to collection of objects. Objects are continuously added in to collection from remote server and same is reflecting in to listview. Now we have requirement that we should be able to freeze listview for some time, That is objects should still get added in to collection but should not appe...

How can I easily view the contents of a datatable or dataview in the immediate window

Sometimes I will be at a breakpoint in my code and I want to view the contents of a datatable variable (or a datatable in a dataset). The quick watch doesn't give you a very clear view of the contents. How can I view them easily? ...

Extend LDAP Membership to append a prefix/sufix to the username

Our web applications are using LDAP Membership Provider to authenticate and register users in Active Directory. In order to allow users to provide usernames that exist in other applications, we need to add a prefix in its username and it should be as transparent and painless as possible. What I need is a way to extend the LDAP Membershi...

Why Encrypt Query Strings in ASP.NET?

I work on a web-application that is written in C#/ASP.NET. The original framers of this application chose to use encrypted query strings and Viewstate to control the 'security' and 'state' of the application. Having come from a GET/POST world before this, I don't have a good basis for understanding why people would go through the troub...

How do I combine two interfaces when creating mocks?

We are using Rhino Mocks to perform some unit testing and need to mock two interfaces. Only one interface is implemented on the object and the other is implemented dynamically using an aspect-oriented approach. Is there an easy way to combine the two interfaces dynamically so that a mock can be created and the methods stubbed for both in...