.net

Can anything make life easier for a dotnet 3.5 coder trapped in a 1.1 world?

I have to spend a fair portion of my time developing in dotnet 1.1, and as I'm sure anyone in a similar position will appreciate, the more I get used dotnet 2.0 and above, the more annoying it is to go back to the early version. I'm getting increasingly fed up of messing about with ArrayLists and the like when I want to be working with G...

How to best implement Equals for custom types?

Say for a Point2 class, and the following Equals: public override bool Equals ( object obj ) public bool Equals ( Point2 obj ) This is the one that is shown in the Effective C# 3: public override bool Equals ( object obj ) { // STEP 1: Check for null if ( obj == null ) { return false; } // STEP 3: equivalen...

Is it possible to dynamically generate a class in .NET?

I'm using [FileHelpers library][1] [1]: http://www.filehelpers.com/ to process Excel spreadsheet and CSV file. FileHelpers require user to generate a class in order to extract the data out of the spreadsheet that is mapped exactly as the data on the spreadsheet. It come with a wonderful wizard to generate the class without manually ty...

Getting a list of file associations

I have a program that is supposed to save reports in different file formats, and if there is an application associated with the file extension, then open that file using that application. Is is possible to get all file extensions that have applications associated with them in windows? I tried the registry entry HK_CLASSES_ROOT{extensi...

What should I use for a BigInt class in .NET?

Until BCL finally ships System.Numeric.BigInt, what do you guys use for arbitrary precision integers? ...

How can I save an email instead of sending when using SmtpClient?

I am using SmtpClient to send an email with an attachment. However for a certain batch we need to somehow save the MailMessage instead of sending them. We are then thinking/hoping to manually upload the messages to the users drafts folder. Is it possible to save these messages with the attachment intact (impossible, I would have thought...

Enable Visual Styles for a Class Library

Hi, how do I enable visual styles when my project is a class library and it's being loaded into a program that does not have Application.EnableVisualStyles() set. I have been struggling with this for 2 days now. This is in C# (I've seen some examples for older C++ and some things that may work for VB, but nothing has been clearly laid ...

Implementing a Factory that uses Specifications to determine which type of object to create

This is mainly a thought experiment. So this all is sample code. My goal was to use the specification pattern to eliminate giant blocks of conditional code inside a factory. So with this sample I have a StatusData object that I want to get an implementation of IStatusUpdate that is appropriate for for it. I have the following set of tes...

Using Linqdatasource and groupby property

I have a Linqdatasource that groups the records in table:Routing by a field called SubmitTo. My select statement is this - "new (key as SubmitTo, Count() as Count, it as Routings)". Now the SubmitTo field is only a foreign key reference the primary key in table:Department which has a field:DeptName with the full name of the department. H...

Why would C# ProcessStartInfoRedirectStandardOutput cause xcopy process to fail

This is a bit of a pain because I now don't have the code in front of me, but I'll try to explain. I have a simple C# application that kicks off a Ruby script (it does a couple of other things, so it generates a batch file and executes that). I am using the C# process object and I set the following redirectstandardoutput = true redirec...

How to programatically search a PDF document in c#

I have a need to search a pdf file to see if a certin string is present. The string in question is definately encoded as text (ie. it is not an image or anything). I have tried just searching the file as though it was plain text, but this does not work. Is it possible to do this? Are there any librarys out there for .net2.0 that will ex...

DataGridViewComboBoxCell inactive item painting

Hi All, We're trying to alter the DataGridViewComboBoxCell so that when the user expands the dropdown menu, inactive items are displayed in grey text. I've found out how to do this by creating a new object, which inherits from DataGridViewComboBoxEditingControl. The problem with this, is that I'm not sure how to tell the comboBoxCell,...

Font in Html mail

Using MailMessage email = new MailMessage();email.IsBodyHtml = true; Is it possible to set the font for the message? Also, maybe it's a quirk but p and br tags come out the same for me? Is this normal? Thanks, ...

Loading C# form into ActiveX control

Hi all, Is it possible loading C# form (or C# application) into ActiveX control? I know how to load ActiveX control to C# form.... ...

How do I use WaitHandles safely to prevent deadlocks?

Observe the following pseudo: ManualResetEvent[] resetEvents = new ManualResetEvent[operations.Count]; for( int i = 0; i < operations.Count; i++ ) { resetEvents[i] = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem(new WaitCallback(timeConsumingOpHandler), resetEvents[i]); } WaitHandle.WaitAll(resetEvents); In the case ...

How do I use different Fields in the same column in a DataGridView

I have a, probably unique situation in which I need to use a single column for two different alternating values. My data has seperate columns for date and time. Not my choice, I have to live with it. Rows are displayed in "pairs" Row 1 and 2 are part of the same functional unit, but they are seperate rows in the database. In the gri...

From a development perspective: How do I convice the bosses to upgrade to Vista / Windows 7?

Our current development environment at work is Windows XP pro. It is a fine operating system, but after using Vista and Windows 7 at home, I find myself wanting to use them at work where I spend majority of my time on a computer. The problem lies in that Windows XP does the job, and there's 0 cost in moving forward as obviously its alre...

What is better, many small assemblies, or one big assembly ?

All is in the title :) Currently, we have a VS2005 solution with 20+ projets. Like MySolution MySolution.Modules.Foo MySolution.Modules.Bar [insert many here] MySolution.Modules.Baz Can there be a harm to "merge" MySolution.Modules.* in one project ? All namespaces will be preserved, so no problem here. But is there anything I didn'...

Coding Standards

For those of us that have programmed enough I’m sure we have come across many different flavours of coding standards that you can use when it comes to programming. e.g. http://msdn.microsoft.com/en-us/library/ms229042.aspx You might derive your coding standards for the current company you work for or from the original author of the cod...

What areas of code are you using f# for?

For those of you out there who are using f#, what areas of functionality are you coding with it? What is the language really well suited to and what does it do with far more power and ease than say c#? ...