.net

Useful PowerShell one liners

Provide one line PowerShell script that you found useful, one script per answer please. There is a similar question here, but this one gives only links to pages with scripts, lets answers one by one here and have a contributed list of most frequently used or most useful scripts. 1.List most recent version of files ls -r -fi *.lis | s...

Supporting .NET Framework 3.5 SP1 Client Profile?

Are there any design considerations that need to be made when targeting the .NET Framework 3.5 SP1 Client Profile? I know it's a subset of the full framework, but what is missing and how will I know if my application will require the Client Profile or the full framework? Has anyone successfully developed an application using the Client P...

Predicate on DataView Constructor?

I know this may sound crazy, but I swear that on two separate ocassions via intellisense I've seen an overload for the DataView constructor that took in a DataTable and either Predicate or Func, I don't remember what T was, either DataRow or DataRowView. But now I can't find it. It also took in another parameter, I want to say it was a C...

How to guarantee a NotifyIcon disappears?

Hi, I'm using a NotifyIcon control in one of my child (modal) forms and it is working fine. SHowing balloon tips as expected, handling mouse events etc... It doesn't however vanish when I would expect it to. Specifically, when i exit the child form and the parent is back in control the icon still remains. It's tooltip is accessible so ...

how to do location based search

Hi all, I need to develop a solution that will provide the ability for a user to search based on a city and state. The user should have the ability to request that the search results include not just matches for that city and state, but also include matches in a 25, 50, 100 mile radius. I see that job sites do this type of thing. How is ...

what will be a good regex to extract pure numbers out of "25 10a 36 10b 30"

Hi friends i was in need of a regex which will return only 25,36,30 for me from 25 10a 36 10b 30 as they are the only pure numbers in the sequence. I tried this but it did not work for me : (^|[ ])\d+|($|[ ]) Any suggestions? ...

When should I manually dispose of controls? How do I know if a control implements IDisposable?

In a previous question about ridding the system tray of an old NotifyIcon I was told that I should Dispose anything that implements IDisposable. Sounds like good practise to me however as a newbie it raises more questions :-) How do I know if a control implements IDisposable? Should I build a class that attempts to dispose everything ...

Making an MSSQL Driven Calendar in .NET c#

I'm new to .NET and my first project is to create a event calendar to be populated from a events table in mSQL. I know there is a calendar object in the standard components but wondered if i'm better off populating a table view manually as i didn't know if there were lots of limitations to the standard object/component. Thanks for your ...

How can I make my simple .NET LRU cache faster?

UPDATE: Hey guys thanks for the replies. Last night and tonight I tried a few different approaches and came up with one similar to the one laid out below by Jeff (I had even already done what he suggested in his update, and put together my own simple LL implementation for additional gains). Here is the code, at this point it doesn't lo...

.Net string parsing library, or regex for parsing .Net code files

I would like to be able to parse vb.net code files, so I can examine the collection of Subs, Functions (and their contents, including comments), private variables, etc. I can be open the actual source code files. So for example, if I have: Public Function FunctionOne(arg1 As String, arg2 as String) as Integer here is some code '...

Can I suspend redrawing of a form until I have performed all updates?

Using C# and .Net 2.0, I'm using an irregularly shaped form (TransparencyKey, FormBorderStyle = None, etc...) and want to allow "normal" bordered mode. I change the back colour to default from Lime I change FormBorderStyle to FixedSingle I change the TransparencyKey to Colour.None Unfortuanately this looks a complete mess on screen wi...

How do I hide some of the default control properties at design-time (C#)?

I have a custom control that I made. It inherits from System.Windows.Forms.Control, and has several new properties that I have added. Is it possible to show my properties (TextOn and TextOff for example) instead of the default "Text" property. My control works fine, I'd just like to de-clutter the property window. ...

Replace content in a string based on Regex.Matches MatchCollection

I've been working on this RegEx for the past day or so and I think I have it worked out so that it returns the data I want. First a little background. I have a content editor that users will be able to edit web pages. They can format text, add links, etc.. standard content editor stuff. When they click save, the editor provides the ab...

Subversion Server to use on Windows

What Subversion (SVN) Server would recommend a newbie get started on the Windows Server OS? I think I'll be using TortoiseSVN on the client and will be doing .NET development mostly. UPDATE: Great advice. I'm picking my answer based on votes. I will try VisualSVN and CollabNet. Please read chyne's answer which I thought was really goo...

Maintenance - balancing the question of when and if to make changes

I maintain a couple libraries for other people. After having gone through a couple releases for each of them, there are some things I would do differently, if I had to do them over again. The question is: Should I do them over? I guess we all face that dilemma - how to balance the helpfulness of the maintenance activity versus the d...

Specifing machine key in the web.config

Are there any security risks when specifing the machine key in the web.config on a web farm? ...

How does .net create an SHA1 hash?

Are there built in techniques for doing this? What arguments does it expect? ...

Sending Multi-threaded SendEmail request returns General Mapi Failure

Hi, I'm using the MAPI code by Dave Brooks. I am attempting to programatically send out a Crystal Report that is generated. When I run through the code without threading everything runs fine. The problem is when I use threading I get the return error "General MAPI failure [2]". I have never used threading before and understand that t...

Possible to instantiate and invoke a delegate by name?

I'm trying to figure out if it is possible to instantiate and invoke a delegate by name, rather than explicitly. I think the code belows explains it fairly well....I want to accept a function name, and then instantiate the delegate based on that. In the example I use a select case, but I want to eliminate that and just use the methodNa...

Control.Refresh() Across Threads

OK, please disregard what has gone before. I'm not getting the errors anymore, so it seems my problem is with getting a Chart to update when I change the values to which the Chart is data bound. //Disregard below here Hi all. I have a WinForms application that has a panel, panel1. A background thread creates some other controls that th...