.net

Unit Testing with functions that return random results

I don't think that this is specific to a language or framework, but I am using xUnit.net and C#. I have a function that returns a random date in a certain range. I pass in a date, and the returning date is always in range of 1 to 40 years before the given date. Now I just wonder if there is a good way to unit test this. The best approa...

Join Tables in .NET DataSet to Display in DataGridView

I have two tables in a DataSet in .NET. I want to join them on an ID column. Then I want a DataGridView to display two columns from the first table and one column from the second table. If it makes it easier, the relation between the two tables is one-to-one. Can it be done? ...

.NET/Mono Database Access—Easy column access?

I am not sure if I am missing something grotesquely obvious or what, but I can't seem to figure out how to efficiently access tables in a relational database. I am using PostgreSQL for the database server (and Npgsql for its access) and C# with Mono 2.0. Say I have the table created by the following CREATE TABLE and INSERT statements. ...

MultiMap implementation

I'm writing a simple IDictionary abstraction in C# that wraps a Dictionary<K, ICollection<V>>. Basically, it maps multiple values to one key. I can't decide whether to remove a key and its empty list when the last item in a values list is removed, or leave it (to avoid instantiating a new collection if the key is reused) and do checks ...

What is the easiest way to create and compare a salted password in .NET?

In an ongoing effort to improve my code I am looking for the best way to create and compare a salted password in .NET. Is there a better, or more secure, way of doing this? My current code is as follows: public static string CreateSaltedPassword(string salt, string password) { SHA1CryptoServiceProvider SHA1 = null; ...

How do I store an enum value in a Windows Forms settings file?

I'm using Windows Forms and VS2008. I want to store an enum value in my application's settings file. The settings editor in VS2008 only gives me a limited set of types. Amazingly, enums don't seem to be one of these types that are automatically supported - have I understood this correctly? From reading up on the subject, it seems lik...

What advantages does using Oslo and M have and when would you use it?

After attending a talk on Oslo/M I am struggling a bit to see the advantages of using it over existing methods and in what situation it would be useful. I know its quite new and not all details have been released etc but can some one give me some advantages and when you might use it? Thanks, Alex ...

A COBOL programmer thinking about switching to the modern world

I would like to know what are the best options for a COBOL programmer to switch to more modern platforms. I explored Java but will all its frameworks its overwhelming. .NET appeared much simpler but I'm worried if it will result in a vendor lock-in; we have had enough of it with COBOL. What about other choices such as LAMP, Ruby On rai...

.Net reference problem

I am writing an application using the Microsoft enterprise library. I wrote a wrapper dll for that enterprise library dll. I want to use my wrapper in some windows form application. The problem is that every time I want to use my wrapper I get an error in the compilation that says that a reference to the enterprise library dll is missing...

Ways to use .Net within MS Access

I'd like to include custom .Net controls and .Net forms within MS Access. It's possible but I was wondering if there was any new good articles on that subject. Over time I've found a few related to the subject the but always found the process a bit cumbersome (see references below). One of the issue is deployment: my user's machines hav...

Learning C#

I have good experience in working with C++ and know basic Java as well. I want to learn .NET framework in general and C# in particular. How should I go about it? ...

TIBCO.EMS .NET client / WCF channel

Folks, TIBCO has announced support for WCF channels back in April - has anything of that materialized by now?? Where and how can I download either these new WCF channel bits, or where can I get my hands on a current .NET 2.0/3.5 version of the "TIBCO.EMS .NET client library" ?? We're a small ISV without any ties to TIBCO so far, but ...

Removing or overwriting a component from Windsor Container

I'm trying to accomplish a seemingly super simple thing: from my unit test I want to replace the type being resolved with a mock/fake object. For example: the xml config states that a component of the service IInterface should resolve to ClassA. That's fine, but from my unit test I want the type to resolve to FakeClassA instead. I can't...

is it safe to keep database connections open for long time

I have a .net client application which is connected to a remote database. Is it safe to keep a single connection open for the lifetime of the client (hours)? Does the answer hold if I have multiple (10 or 100) clients running? Thanks ...

TDD with Episerver

What is the best way to abstract the episerver infrastructure for easier testing? ...

Proper .NET DLL structure for app

...if there is such a thing. Here's an image of two approachs for structuring DLLs/references in a .NET application: http://www.experts-exchange.com/images/t80668/compArch.png. The app can be a website (it is in this case) or a winform. Each box represents a DLL. For the winform app, just replace "webcontrols" with "winformcomponent...

How Can I Convert Types at Runtime?

My scenario should be simple... the type I want to convert FROM is ALWAYS 'string'. What I want to convert to... could be many things - ints, DateTimes, ... strings, etc. This would be easy: string valueToConvertFrom = "123"; int blah = Convert.ToInt32(valueToConvertFrom); However... I don't know (until runtime) that the value I nee...

How to get a .NET CCW assembly to load configuration from a dll.config

I have a .NET component exposed as a CCW (Com Callable Wrapper) and being loaded into an unmanaged IIS application (ATL server). The assembly is installed and registered with COM using regasm /codebase. The component requires configuration such as is typically put into a Web.config file for an IIS app. But I don't want to drop the con...

Pass value to form in .Net

I want to pass an integer value to a form in .Net so that it can load the right data. I'm using this so that when I double click on a record in a list, a form opens with the data from that record loaded so it can be edited. What is the best way to do this? Should I create a property and set it before calling the Show() method, or should ...

Strange Choppy WPF Animation

I am making an app that scrolls information on the desktop. The window is transparent. I am starting out simple, trying to find the lowest CPU use for animating things and I am starting with a simple TextBlock. On my development machine, I get a very smooth animation across the screen setting the Canvas.Left property with a DoubleAnim...