.net

How do I calculate CRC32 of a string

How do I calculate the CRC32 (Cyclic Redundancy Checksum) of a string in .NET? ...

When should I use Compiled LINQ vs Normal LINQ

I just read up on a performance of LINQ, and there is a HUGE amount to be gained by using Compiled LINQ. Now, why won't I always use compiled LINQ? ...

Connection Pooling in .NET/SQL Server?

Is it necessary or advantageous to write custom connection pooling code when developing applications in .NET with an SQL Server database? I know that ADO.NET gives you the option to enable/disable connection pooling -- does that mean that it's built into the framework and I don't need to worry about it? Why do people talk about writing...

Unit of Work Pattern in .Net

Does anyone have any concrete examples of a simple Unit of Work pattern in C# or Visual Basic that would handle the following scenario? I'm writing a WinForms application in which a customer can have multiple addresses associated with it. The user can add, edit and delete addresses belonging to the customer before the customer is saved...

Using unhandled exceptions instead of Contains()?

Imagine an object you are working with has a collection of other objects associated with it, for example the Controls collection on a WinForm. You want to check for a certain object in the collection, but the collection doesn't have a Contains() method. There are several ways of dealing with this. Implement your own Contains() method...

Visual Studio Optimizations

Visual studio is a pretty awesome IDE, but sometimes you just wish it would go faster. I was wondering if people have any tips or tricks to help speed up visual studio in day to day use. Things that I'm particularly interested in are speeding up build times and switching aspx files from source to design view seem to bring it to a grindi...

Watch for change in ip address status

Is there a way to watch for changes in the ip-address much the same as it is possible to watch for changes to files using the FileSystemWatcher? I'm connecting to a machine via tcp/ip but it takes a while until it gives me an ip-address. I would like to dim out the connect button until I have a valid ip-address. ...

HTML Email Editor in a Windows Forms Application

We are looking for a WYSIWYG editor control for our windows application (vb.net or c#) so that users can design HTML emails (to send using the SMTP objects in the dot net framework) before sending. Currently all the available editors we can find have one of the following issues: a)They rely on mshtml.dll or the web browser control whic...

Numerical formatting using String.Format

Are there any codes that allow for numerical formatting of data when using string.format? ...

Entity Framework vs LINQ to SQL

Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the .NET entity framework. My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big bro...

How do you use PowerShell?

Windows PowerShell came out last year and got great reviews from many .net bloggers (Hanselman comes to mind). It seemed to be touted as a great new utility that somehow made everything that you would ever do on the command line easier, and integrated with .Net. However, the more I read about it, the more it seems to be a tool that is gr...

Getting accurate ticks from a timer in C#

I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough. For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every .5 seconds (or 500 milliseconds). ...

Printing a PDF in .NET

It's the "printing question guy" again. Looking for a third-party solution to print PDFs, preferable from a service. I have seen some arguments against it, but due to our use case, this really is the preferred solution - the service will be receiving messages from a messaging bus, and there shouldn't be any sort of delay between the re...

Best way to play MIDI sounds using C#

I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in .NET using C#. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks". I've found a few articles online about playing MIDI in .NET, but most of them seem to rely on cust...

Using C#/WIA version 2.0 on Vista to Scan

I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem. In each and every one of them, the reference to WIALib is broken. When I go to add...

Calling Table-Valued SQL Functions From .NET

Scalar-valued functions can be called from .NET as follows: SqlCommand cmd = new SqlCommand("testFunction", sqlConn); //testFunction is scalar cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("retVal", SqlDbType.Int); cmd.Parameters["retVal"].Direction = ParameterDirection.ReturnValue; cmd.ExecuteScalar(); int aFuncti...

Hidden Features of C#?

This came to my mind after I learned the following from this question: where T : struct We, C# developers, all know the basics of C#. I mean declarations, conditionals, loops, operators, etc. Some of us even mastered the stuff like Generics, anonymous types, lambdas, LINQ, ... But what are the most hidden features or tricks of C# th...

Accessing audio/video metadata with .NET

What is the best way to get and set the meta data for mp3, mp4, avi files etc. with .NET? ...

Lingering assembly dependency in C# .NET

My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate. This project used to throw and catch a custom exception class - the SuperException - which was derived from the stan...

IL level code debugger

Hi, Is there any IL level debugger in form of a VS plugin or standalone application? Visual studio’s debugger is great, but it allows you to debug on either HLL code level or asselbly language, you can’t debug IL. It seems that in some situations it would be useful to have an opportunity to debug at IL level. In particular it might b...