.net

Is there a way to define an action for unhandled exceptions in a WinForms .NET 3.5 app?

Note, I realize that this has been addressed here. That post discusses exception handling in .NET 1.1 while implying that there is a better solution for >.NET 2.0 so this question is specifically about the more recent .NET versions. I have a windows forms application which is expected to frequently and unexpectedly lose connectivity to...

How can I keep a class from being inherited in C#?

In java, I could do this with the 'final' keyword. I don't see 'final' in C#. Is there a substitute? ...

Can I split a string in c# VB6-style without referencing Microsoft.VisualBasic?

Unfortunately, there seems to be no string.Split(string separator), only string.Split(char speparator). I want to break up my string based on a multi-character separator, a la VB6. Is there an easy (that is, not by referencing Microsoft.VisualBasic or having to learn RegExes) way to do this in c#? EDIT: Using .NET Framework 3.5. ...

TableLayoutPanel

does the TableLayoutPanel exist in VS 2005? ...

Can I test a floppy drive using WMI & System.Management namespace?

I would find out the floppy inserted state: no floppy inserted unformatted floppy inserted formatted floppy inserted Can this determined using "WMI" in the System.Management namespace? If so, can I generate events when the floppy inserted state changes? ...

Inherit IEnumerable from Object consequences

I posted an answer to this question, including a very short rant at the end about how String.Split() should accept IEnumerable<string> rather than string[]. That got me thinking. What if the base Object class from which everything else inherits provided a default implementation for IEnumerable such that everything now returns an Enume...

Reading .resx files programatically

I have an application where the contents of e-mails that get sent are stored in a .resx file. This is an ASP.Net application, the .resx file lives in /App_GlobalResources When I need to send an e-mail, i'm reading this using: HttpContext.GetGlobalResourceObject("MailContents", "EmailID").ToString Now, I need to use the same maili...

What is the easiest way to find out how much memory an object uses in .NET?

What is the easiest way to find out how much memory an object uses in .NET? Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types. Some related posts: Object Memory Analysis in .NET Does an empty array in .NET use any space? ...

How can you inherit from a sealed class using reflection in .Net?

Before you start firing at me, I'm NOT looking to do this, but someone in another post said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things... ...

IE hosted .net user control using an unmanaged dll

What's a good way for an IE hosted .net user control (e.g., < object classid="myctrl.dll#init">) to pull down an unmanaged dll for it to use? For Click-once, this is easy with a manifest, but ie hosted controls don't get installed in the click-once app cache and instead run out of the download cache. Copy the dll there? Or into the t...

How can I share application configuration in a .net application?

I've got a relatively large .Net system that consists of a number of different applications. Rather than having lots of different app.config files, I would like to share a single configuration file between all the apps. I would also like to have one version when developing on my machine, one version for someone else developing on their ...

Embedded Web Server in .NET

I would like to embed a light weight web server in a Windows application developed in .NET. The web server has to support PHP. I have looked at Cassini, but it seems it is ASP.NET only. Any idea? ...

What is the "< >" syntax within C#

I have been learning about the basics of C# but havent come across a good explenation of what this is. var l = new List<string>(); I dont know what the < string > is doing or if its the List that is doing the magic. I have also seen objects been thrown within the < > tags. Can someone explain this to me please with examples. ...

.NET - How can you split a "caps" delimited string into an array?

How do I go from this string: "ThisIsMyCapsDelimitedString" ...to this string: "This Is My Caps Delimited String" Fewest lines of code in VB.net is preferred but C# is also welcome. Cheers! ...

How do I get a Video Thumbnail in .Net?

I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail. Something along these lines should work: // filename examples: "test.avi", "test.dvr-ms" // position is from 0 to 100 percent (0.0 to 1.0) // returns a bitmap byte[] GetVideoThumbnail(string filename, float position) ...

What are the best resources for learning CIL (MSIL)

I'm an expert C# 3 / .NET 3.5 programmer looking to start doing some runtime codegen using System.Reflection.Emit.DynamicMethod. I'd love to move up to the next level by becoming intimately familiar with IL. Any pointers (pun intended)? ...

Why do I need OleDbCommand.Prepare()?

I'm working with a datagrid and adapter that correspond with an MSAccess table through a stored query (named "UpdatePaid", 3 paramaters as shown below) like so: OleDbCommand odc = new OleDbCommand("UpdatePaid", connection); OleDbParameter param; odc.CommandType = CommandType.StoredProcedure; param = odc.Parameters.Add...

Difference between a BitmapFrame and BitmapImage in WPF

What is the difference between a BitmapFrame and BitmapImage in WPF? Where would you use each (ie. why would you use a BitmapFrame rather than a BitmapImage?) ...

FIPS compatible password encryption for .NET

I've working on a WinForms in VB.NET (3.5) application that requires the user to enter domain administrator credentials. To make things easier on the user, they should only have to enter the user name and password once, and then just rely on my app to save these credentials. I'd like to save these credentials with the other user settings...

The best way to assert pre-condition and post-condition of arguments and values in .NET?

I have been thinking about design by contract lately and I was wondering what people think is the best way to assert pre-condition and post-condition of values in .NET? i.e. validating argument values to a method. Some people recommend Debug.Assert while others talk about using an if statement plus throwing an exception. What are the pr...