.net

How do you deal with transport-level errors in SqlConnection?

Every now and then in a high volume .NET application, you might see this exception when you try to execute a query: System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. According to my research, this is something that "just happens" and not much can be done to prevent it. It...

ArgumentNullException for Integer

In .NET, is it more appropriate to throw an argument null exception for an Integer if the value is Integer.MinValue or Integer = 0 (assuming that 0 is not a valid value)? ...

Creating tempory folders

I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem? ...

PHPs htmlspecialcharacters equivalent in .NET?

PHP has a great function called htmlspecialcharacters() where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's almost a one stop shop for sanitizing input. Very nice right? Well is there an equivalent in any of the .NET libraries? If not, can anyone link to any code samples or libr...

How do you download and extract a gzipped file with C#?

I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#? ...

Escaping XML tag contents

I have a simple CAML query like <Where><Eq><Field="FieldName"><Value Type="Text">Value text</Value></Field></Eq></Where> And I have a variable to substitute for "Value text". What's the best way to validate/escape the text that is substituted here in the .NET framework? I've done a quick web search on this problem but all what I found...

What's the best way to authenticate over WCF?

What's the best way to implement authentication over WCF? I'd prefer to not use WS-* as it needs to be transport independant. Should I "roll my own"? Is there any guidance for doing that (articles/blog posts)? Or is there some way to (and should I) use the built in ASP.NET Membership and Profile providers on the server side? ...

What are real life applications of yield?

I know what yield does, and I've seen a few examples, but I can't think of real life applications, have you used it to solve some specific problem? (Ideally some problem that cannot be solved some other way) ...

When to use IList and when to use List

I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type? ...

What's your top feature request for Silverlight?

I'll take away the obvious one here: mic and webcam support. Other than that, if you ran the Silverlight team, what would your highest priority be for Silverlight v.Next? Disclaimer: If we get some good responses, I'll pass them along to folks I know on the Silverlight team. UPDATE: The best place to report Silverlight feature requests...

Privatizing a BlogEngine.Net Installation

I have a blogengine.net install that requires privatization. I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met. How can I privatize my blogEngine.net install so that readers must log in to read my posts? ...

ASP.NET Custom Controls - Composites

Summary Hi All, OK, further into my adventures with custom controls... In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong! UserControls - Which inherit from UserControl and are contained within an ASCX file. These are pretty limited in what they...

Request Windows Vista UAC elevation if path is protected?

For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation. So, how do I check if a path is UAC protected and then how do I request elevation mid-execution? Thanks. ...

Non Public Members for C# Interfaces

In C#, when you implement an interface all members are public by default. Do you think it's better if we can specify the accessibility modifier (protected, internal, except private of course) or better use an abstract class instead? ...

How do you place a file in recycle bin instead of delete?

Programmatic solution of course... Man i wish i could choose both the VB and Unmanaged as an answer ;) Thanks for both. ...

Why does Guid.ToString() reverse the byte order?

We're storing some Guids in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a uniqueidentifier parameter. When you look at the results using MS SQL Management studio they look different. The byte order of the first three b...

Anyone know a quick way to get to custom attributes on an enum value?

This is probably best shown with an example. I have an enum with attributes: public enum MyEnum { [CustomInfo("This is a custom attrib")] None = 0, [CustomInfo("This is another attrib")] ValueA, [CustomInfo("This has an extra flag", AllowSomething = true)] ValueB, } I want to get to those attributes from an ...

Warning C4341 - 'XX': signed value is out of range for enum constant

When compiling my C++ .Net application I get 104 warnings of the type: Warning C4341 - 'XX': signed value is out of range for enum constant Where XX can be WCHAR, LONG, BIT, BINARY, GUID etc. I can't seem to remove these warnings whatever I do. When I double click on them it takes me to a part of my code that uses OdbcParameters - an...

Getting the Remote Name Address (not IP)

Hi, I wanted to show the users Name Address (see: www.ipchicken.com), but the only thing I can find is the IP Address. I tried a reverse lookup, but didn't work either: IPAddress ip = IPAddress.Parse(this.lblIp.Text); string hostName = Dns.GetHostByAddress(ip).HostName; this.lblHost.Text = hostName; But HostName is the same as the IP...

Warning: Found conflicts between different versions of the same dependent assembly

I am currently developing a .NET application, which consists of 20 projects. Some of those projects are compiled using .NET 3.5, some others are still .NET 2.0 projects (so far no problem). The problem is that if I include an external component I always get the following warning: "Found conflicts between different versions of the same ...