.net

CLI nested generic types and generic methods

Have I stumbled upon implementation-defined behavior? Here is the context: public class GenericClass<T> { public class NestedGenericClass<U> { public void GenericMethod<K>() { } } } Here's the behavior. This unit test passes as written. My actual questions are listed as the comment before the "wack...

Searching for controls in Request.Form / Parsing a NameValueCollection

I am searching for control names using Request.Form. Of course I know you can can iterate around all values using AllKeys, and you can do Form["controlName"] as well. However some of my control names are dynamic and it would be useful to be able to do stuff like: 1)Getting a subset of controls in the collection whos name start with a ...

How could ProcessStartInfo.UseShellExecute = false result in odd behavior by FreeImageNet on a separate thread?

I am running a Process in a BackgroundWorker to resize images. If I set UseShellExecute = false on the process's startinfo, I get odd behaviour if I do any simultaneous image manipulation with the FreeImageNet library on the UI thread. The odd-behaviour is that when I go to close a new image via CloseMultiBitmap() the method appears to w...

How to export 'date lookalike' text columns to csv

Hello all, I have the .net code written to export data to a csv file. The problem is that one of the columns has data like 5-8-13 When I double click the .csv file in excel this column shows data as 5/8/2013 i.e. it is misinterpreted as a date column which is not what I want. Is there some escape character which I can use while exporti...

Efficient searching of NameValueCollection

Is there a way to pull out keys from a NameValueCollection that pertain to a certain pattern/naming convention without having to iterate through every value in the collection? ...

Example of getting country and state/city from google maps api using .net

Hi does anyone have a snippet of sample code to get country and state/city via the Google Maps API of a request from an asp.net application (in code behind)? Any help much appretiated! Thanks! ...

If an app gives me the System.ArgumentOutofRangeException, does that mean it is a bug in the app?

I have this problem with an app of a printer. I need to know if it is an error in my installation or a bug in the app. I think it is a bug (programmer didn't catch this exception), and I suspect this app is made in C# and they didn't noticed the uncaught exception when they upgraded their printers (The fact is that they added a character...

Which .Net component should be used for tcp/ip sockets communication?

We need to talk to another system that wants to communicate to us via raw tcp/ip socket communication. What would be the appropriate .Net object, if any, to use for this? If you know of a 3rd party component, open source component, etc., that you think is better to use, please feel free to mention that as well. ...

How can I expose an Office file using Silverlight?

I'd like to expose Office (Excel, Word) files from a web site. I understand Office 14 now provides Silverlight components to view/edit Office files. What do I need to setup on my web site to use these components? ...

When should I use the HashSet<T> type?

I am exploring the HashSet<T> type, but I don't understand where it stands in collections. Can one use it to replace a List<T>? I imagine the performance of a HashSet<T> to be better, but I couldn't see individual access to its elements. Is it only for enumeration? ...

What is the most elegant way to implement a business rule relating to a child collection in LINQ?

I have two tables in my database: Wiki WikiId ... WikiUser WikiUserId (PK) WikiId UserId IsOwner ... These tables have a one (Wiki) to Many (WikiUser) relationship. How would I implement the following business rule in my LINQ entity classes: "A Wiki must have exactly one owner?" I've tried updating ...

What happens if we add lines to IL code and add breakpoints to our program?

If I add let's say 1 line at the beggining of a method, if I set a breakpoint through Visual Studio on the first line, will it point to the first line or the second? If it will flag the wrong line, is there anything we could do when editing .exe files to ensure a regular debugging session later? Isn't there something like setting line x...

Forcing a culture on an application

How can I force and application and any threads that are started by that application to run under a specific culture? I have tried the following but I still get exceptions in English. My understanding was that the wording on exceptions are translated using the active culture. static void Main(string[] args) { Thread.C...

Regex for all PRINTABLE characters

Is there a special regex statement like \w that denotes all printable characters? I'd like to validate that a string only contains a character that can be printed--i.e. does not contain ASCII control characters like \b (bell), or null, etc. Anything on the keyboard is fine, and so are UTF chars. If there isn't a special statement, how c...

What lesser known parts of the ".NET Application Development Foundation" exam have you actually used and in what context?

For various reasons I have decided its time to take some .NET exams, I'm starting with 70-536, Microsoft .NET Framework 2.0 - Application Development Foundation. As part of the study, I'm going through some practice tests and realise there is a lot of stuff that I've never or rarely used in 6-7 years of .NET experience (mostly building...

In vb2005.net is there a function that works like the php function "htmlentities"

In VB 2005 .Net is there a function that works like the php function "htmlentities"? ...

Dictionary of Action<T> Delegates

I have object XML serialized messages coming into a class called MessageRouter. The XML contains the Type name it it was serialized from, and I need to be able to invoke different delegate methods depending on the type that are not known until runtime. I'm not extremely strong in generics so hopefully this will make sense to someone... ...

In vb2005 how do you simulate a web browser's file download using Net.HttpListener

In vb2005 how do you simulate a web browser's file download using Net.HttpListener? This current program functions somewhat like a webserver. how when a client from a web browser asks for a file do i allow them to down load the file? currently the method will tell the browser that there is a file but it will fail after the client oks th...

C#: List all processes and their current memory & CPU consumption?

Hello, how can I get a list of all processes in C# and then for each process current memory and CPU consumption? Sample code is highly appreciated. Thank you! ...

C#: Paint own Bar Chart

Hello, I'm trying to paint a simple bar chart via C# but I've never experimented with the Graphics and Drawing namespaces. I thought of generating a "start" and "end" graphic and then repeating an image somehow (to show a "length") but I have no idea how to do this. I'd be really happy if you can point me in the right direction and/or ...